trash

This is not true...

From: smith@canon.co.uk (Mark Smith)  
Newsgroups: talk.bizarre  
Subject: Re: Real Unix Users

I once mistyped 'cal 1976' as 'su -c "mount -a; rm -rf /"' and then I fainted, accidentally spelling out the root password with my forehead just before my right hand fell on the return key and the cigarette dropped out of my left hand onto the backup tapes.

No wonder they call it an unfriendly operating system.  

This is true...

Once upon a time, I was unwisely logged in as root on a production system. For reasons that made sense at the time, I typed the command

rm -r ../bin

... and saw the message

rm: cannot remove directory: '..'

... because I fat-fingered a space in the middle and actually typed

rm -r .. /bin

... and in the time it took to realize that, most of /bin was gone. It turns out that Linux doesn't run very well without /bin.

Now I spend most of my time on OS X without the root user enabled, but rm is still there, eager to do what I tell it to do, not what I want it to do.

And that's why this tiny script is my best friend.

#! /bin/sh

DIR=~/.Trash/`date "+%y%m%d.%H%M%S"`

mkdir $DIR

while [ $# -ne 0 ]  
do  
  mv "$1" $DIR
  shift
done  

Save it as trash on your path, and use it instead of rm:

$ trash aFile aDirectory anotherFile etc

It will create a timestamped directory in your Trash and move all of its arguments there, out of the way but not actually deleted until the Trash is emptied.

Update: Just install the node package trash.