1 points · by jabo · 15y ago · 3 comments
I'm thinking of writing a 'replacement' utility of sorts for /bin/rm. I'll rename the existing rm command to say rmx or something and use my version of /bin/rm instead. When you type rm at the prompt, my replacement utility will actually move the files to a "Trash Can" in the file system, instead of deleting it it. And when you type, say 'rm --rm' it will by pass the Trash can and delete the file. And something like 'rm --restore [filename]' will restore the file to its original location.
This way accidental deletions are prevented. Does a utility like this exist already, so that I don't re-invent the wheel?
mv data ~/tmp/
cd ~/tmp/
rm -rf data
At least when I'm in the tmp directory I can see that clearly on the command line so I'm more comfortable issuing dangerous commands.I suppose there might be room for a formal utility, but sometimes you just have to be careful. Take for example my "build" script for Fexl (at https://github.com/chkoreff/Fexl/blob/master/src/build). There you will see these lines:
# I don't use $obj and $bin here because that would be dangerous if I made
# a mistake setting them above.
rm -rf ../obj
rm -rf ../bin
If I were not being so careful, I could simply say: rm -rf $obj
rm -rf $bin
Because after, all, the $obj and $bin variables are "guaranteed" to point to safely disposable directories. Heh. Famous last words. Redundancy is key to reliability.That's not to say it couldn't be improved upon, though.
Also keep good backups. As soon as I read the article it reminded me to plug in my 2tb drive and run timemachine.