
shred_file
Source (link to git-repo or to original if based on someone elses unmodified work):
Description:
------------------------------------------------------------------------------
***CAUTION***
Do NOT use on device files like /dev/hda.
If you need to shred these files, refer to the shred man pages.
***CAUTION***
Use of this script on a file will make recovery impossible,
even with the more expensive file recovery solutions.
This script will shred the input file, after confirmation.
You will also be notified, when shredding is complete. (Should this be
removed?)
Depends
-------
*Obviously you need to have the shred utility installed and in your $PATH.
Since there are some misconceptions/worries about the shred utility regarding ext3, I will put it simple:
If your /etc/fstab file contains an entry for an ext3 partition, and that entry uses 'data=journal',
then the shredded file can still be recovered. If your /etc/fstab file contains an entry for an ext3
partition, and that entry uses 'data=ordered' or 'data=writeback', then your file is gone for good.
*This script also makes use of zenity (http://freshmeat.net/projects/zenity)
This also works well as a Nautilus Action. See the included screenshot for my example configuration.
See README for more info Last changelog:
***CAUTION***
Do NOT use on device files like /dev/hda.
If you need to shred these files, refer to the shred man pages.
***CAUTION***
Use of this script on a file will make recovery impossible,
even with the more expensive file recovery solutions.
This script will shred the input file, after confirmation.
You will also be notified, when shredding is complete. (Should this be
removed?)
Depends
-------
*Obviously you need to have the shred utility installed and in your $PATH.
Since there are some misconceptions/worries about the shred utility regarding ext3, I will put it simple:
If your /etc/fstab file contains an entry for an ext3 partition, and that entry uses 'data=journal',
then the shredded file can still be recovered. If your /etc/fstab file contains an entry for an ext3
partition, and that entry uses 'data=ordered' or 'data=writeback', then your file is gone for good.
*This script also makes use of zenity (http://freshmeat.net/projects/zenity)
This also works well as a Nautilus Action. See the included screenshot for my example configuration.
See README for more info
1.0:
20111205
Complete rewrite by warserv. Wanna take this over? Email me.
This version will display a confirmation dialog; it can handle file paths with spaces in them; it catches and displays stderr from shred; and it displays a zenity progress bar.
0.2:
20100402
Updated to support shredding multiple files. Thanks jbom.
0.1:
20070907 Script release
Ratings & Comments
13 Comments
This version will display a confirmation dialog; it can handle file paths with spaces in them; it catches and displays stderr from shred; and it displays a zenity progress bar. Use at your own risk, of course. [code] #!/usr/bin/env bash nfiles="$#" files="" for file in "$@" ; do if [ ${#files} -gt 0 ] ; then files="$files\n"; fi files="$files$file" done zenity --question --title="shred these $nfiles files - REALLY??" --text="$files" if [ "$?" = 1 ] ; then exit $? else nfile=0 (for file in "$@" ; do echo "# shredding $file..." shredout=$(shred -u -z -n 1 "$file" 2>&1) rc=$? if [ $rc -ne 0 ] ; then echo "100" zenity --error --title="No break for you today" --text="$shredout" exit $rc else let nfile++ echo $((nfile * 100 / nfiles)) fi done ) | zenity --progress --title="Wiping files..." --auto-close \ --percentage=0 --text="starting..." --no-cancel fi exit 0 [/code]
Small revision to display just file basenames, not full paths. [code] #!/usr/bin/env bash nfiles="$#" files="" for file in "$@" ; do if [ ${#files} -gt 0 ] ; then files="$files\n"; fi files=$files$(basename "$file") done zenity --question --title="shred these $nfiles files - REALLY??" --text="$files" if [ "$?" = 1 ] ; then exit $? else nfile=0 (for file in "$@" ; do echo \# shredding $(basename "$file")... shredout=$(shred -u -z -n 1 "$file" 2>&1) rc=$? if [ $rc -ne 0 ] ; then echo "100" zenity --error --title="No break for you today" --text="$shredout" exit $rc else let nfile++ echo $((nfile * 100 / nfiles)) fi done ) | zenity --progress --title="Wiping files..." --auto-close \ --percentage=0 --text="starting..." --no-cancel fi exit 0 [/code]
Thanks. I have updated to reflect these changes. I don't really want to maintain this anymore. Anyone want it?
Thank you very much for this!
hi...was wonderin if there r any probs with the script on ext 4...please let me know..thanx in advance...
Going to try this out...
Hi, thanks for it. Recently changed to gnome (ubuntu) and tried to implement this into nautilus. it works pretty well for single file... how can i get around -or do you have a fix for- for selecting multiple files at once and --> "shred". or did i made a mistake ? i tried to change action settings while configuring nautilus, and selected 'let it be appear when multiple files are selected', it appears, but then when i select 'shred', it shreds only the first file in selection and stops. any idea how i can get around this ? Thanks in advance.
Hi, This is the first response I have made on any forum and the first time I have put any code up (glad to do it finally) so excuse me if I don't do this right. Thanks for the original script, it opened my eyes. I modified it slightly so it handles multiple files and sets the number of passes to 1 (I was using it on a sd card). I think 1 pass for most media is good enough for normal people, you can change it by modifying or removing the -n 1 argument to shred. Seems to work ok. files="$@" zenity --question --title="Shred" --text="Are you sure you wish to shred $# files: $files?" if [ "$?" = 1 ] ; then exit $? else shred -u -z -n 1 $files zenity --info --text="$# files shredded: $files." fi
Awesome thanks, updating.
Nice idea...I've been looking for a simple little script to destroy files. The fact that it can be used in the nautilus actions is pretty cool too. Unfortunately I can't get it to work. I set up up, rightclick, shred, and it says "are you sure?", and I click yes. It says its done and accomplished but the file is still there. However I'm using XFS (whoot!) but I guess that's causing trouble. I have zenity but it still ain't working. I hope this has been any bit helpful and I hope that it can be made to work for all FS's.
Try running the script via the command line: $HOME/.gnome2/nautilus-scripts/shred_file somefile_to_shred That should help shed some light as to what's going on. You should have zenity though if you say you got a dialog box after starting the script. Do "whereis zenity" to find out for sure.
if running the script from the cli works OK, it would have to be your Nautilus action. I included a screenshot in the tarball that is not posted here, showing an example (my) nautilus action setup for reference. If you get errors on the cli, post here and I will see what I can do for you.
thanks man...it was the %M that was missing. After that, it worked fine. Not sure if it'll work in the long run because of me running XFS but the first step is done...