//View Tip #94
Similar Tips
» Remove empty directories
» Manipulate Bash sockets using /dev/tcp
» ESC-g for glob expansion in bash
» Bash
» Change extension of files in the current directory


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;
filesize=`wc -c "$1" | awk '{print $1}'`
`dd if=/dev/zero of=$1 count=$filesize bs=1`

View Comments »


Add your comment

Comments are currently disabled
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
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