JP Vossen on 14 Aug 2010 12:30:21 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] using rm -rf


Date: Sat, 14 Aug 2010 00:00:14 -0400
From: Gordon Dexter<gordon@texasdex.com>
>
I know I'm not the best shell scripter but this one seems to work.
Watch out though, I once managed to accidentally delete the contents of
/bin on one of the campus servers with a shell script I wrote that was
supposed to delete old webcam images.:-)
[...]
     rm -rf $TMPDIR/snap_*

Watch out for that kind of thing. This one is OK, but guess what happens if:
	unset TMPDIR
	rm -rf $TMPDIR/*


When using 'rm', and especially 'rm -rf' you want to really carefully consider what will happen if variables are either unset or unexpected (e.g. from user input)! When in doubt test by prepending an 'echo':
	echo rm -rf $TMPDIR/*

Later,
JP
----------------------------|:::======|-------------------------------
JP Vossen, CISSP            |:::======|      http://bashcookbook.com/
My Account, My Opinions     |=========|      http://www.jpsdomain.org/
----------------------------|=========|-------------------------------
"Microsoft Tax" = the additional hardware & yearly fees for the add-on
software required to protect Windows from its own poorly designed and
implemented self, while the overhead incidentally flattens Moore's Law.
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug