Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Prevent rm disasters' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Prevent rm disasters
Authored by: Anonymous on Oct 03, '05 12:47:32PM
At the risk of being flamed for this, if you say rm -rf * then you get exactly what you asked for. Yes: one slip and it's gone. In my own novice days, I managed an rm -rf .* -- which was fun. (I recommend it on a non-critical system. Great experience fixing it!)

I'd say rm -rf !* is still too easy to get wrong. What if you were thinking of something else and typed it into the wrong shell? What if you missed the bang? What if you were thinking "I will not type space star" and your fingers typed "space star" just to spite you? My own belt-and-braces drunken-safety-mode approach:

$ ls -l php5*
$ ^ls -l^rm -rf
Here, rather than taking the last command's arguments, you're making a wild switcheroo from ls -l to rm -rf -- which amounts to the same thing, but what's the chances of having just typed ls -l as the last thing in that other shell? And here, a stray space or an extra keybounce won't cause untold damage.

[ Reply to This | # ]