Created
June 9, 2021 10:09
-
-
Save rojenzaman/a046667549f5e6547d2e6b32132d376d to your computer and use it in GitHub Desktop.
BASH script to write zeros to file before remove | Use for non-secure HDD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# use find exec to remove multiple files: | |
# find path/to/dir -exec ./rmzero {} \; | |
if [ "$#" -lt 1 ]; then | |
echo "./`basename $0` <file>"; | |
exit 1; | |
fi | |
function load() { FILE="$(realpath $1)" ; MB_COUNT="$(du -m $FILE | awk '{print $1}')" ; } | |
function main() { dd if=/dev/zero of="$FILE" bs=1M count=$MB_COUNT ; rm $FILE ; } | |
load "$@" &>/dev/null | |
if [ -f "$FILE" ]; then | |
main &>/dev/null & | |
else | |
echo "$FILE is not a file." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment