Review my idea: Preventing accidental usage /bin/rm
The problem of accidentally deleting files using rm seems to common, dangerous and painful. Like here: http://news.ycombinator.com/item?id=2661209.
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?
(
3 comments
| on HN
)
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:
If I were not being so careful, I could simply say: 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.