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<>
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/*

JP Vossen, CISSP            |:::======|
My Account, My Opinions     |=========|
"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         --
Announcements -
General Discussion  --