While writing a Python script one day to do a little screen scraping and reporting, the topic of data loss came up between a friend and myself. I was bragging that I had never in my life accidentally lost a single file or piece of data that I wasn’t able to recover. Literally seconds later, while intending to rename my script using “mv”, I accidentally typed “rm” instead and deleted it.
That was just about the last time I used “rm”. I now use a script which, for no particular reason, I call “rr”. Rather than deleting files and/or directories, it moves them to the trash where they can be easily recovered if necessary. Here’s the script itself (configured to work on OS X):
#!/bin/bash if test $1 then mv $1 ~/.Trash/ fi
Just make the script executable (
chmod 755 rr), drop it in your path, and forget “rm” ever existed.
As always, there are several other ways of doing this (remapping “rm”, making an alias, using the Finder, etc.), so pick the way that works best for you. The important thing is to keep yourself from losing hours of work on the command line like I did.