#! /bin/bash # # Shell skript for secure and relative fast setting to length zero. # It overrites the file with random bytes and sets the file length to # zero. # For secure emptying. # # For using another random number device than /dev/random change # the if-option of dd below. # # First version: with dd and bs=1 (slow). # # TODO: Version which works with special signs like newline in the file # name and which converts the file names with their absolute path # because otherwise find can read them as options if they have the same name. # # rolf dot freitag at email.de 2000 for file in "$@" do size=`find "$file" -printf "%s"` || continue # overrite all bytes of the file # dd if=/dev/urandom of="$file" bs=1 count=$size #(old version) ddrescue -v --max-size=$size /dev/urandom "$file" # set size to 0; see also "Unix Power Tools" > "$file" done exit 0