//View Tip #94
Similar Tips
» Check low space
» CDPATH
» Bash function to decompress archives
» ESC-g for glob expansion in bash
» Store a directory name to come back to

 

Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
Overwrites a file with zeroes.
Put in in your .bashrc or .bash_profile in Mac OS X.

zero() {

case "$1" in
"") echo "Usage: zero <file>"
return -1;
esac
filesize=`wc -c "$1" | awk '{print $1}'`
`dd if=/dev/zero of=$1 count=$filesize bs=1`
}


View Comments »




Comments 

Add your comment

Comments are currently disabled
glennj
The last line should not be enclosed in backticks.

The variables in the last line should be quoted.

Use this method to get filesize to avoid calling awk:
filesize=$( wc -c < "$1" )
Posted 2008-11-13 17:07:34
glennj
also, the case needs to end with ;;
Posted 2008-11-13 17:09:53

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit