I found this alternative to rm some time ago, and it has saved me from a few potential deleting disasters. It's simply a shell script, which I've put in the /bin directory and named it "del". I also created an alias in my .cshrc file, such as:
alias rm /bin/delDon't forget to 'source .cshrc' after your edit.
#!/bin/tcsh[Editor's note: Save the file, make it executable (chmod 755 filename), type 'rehash' to force the shell to find it, and you're good to go. Remember to create an alias for 'rm' if you want this new command to override the old, and I'd recommend keeping it in ~/bin or /usr/local/bin, just to protect it from future upgrades.]
# del Moves the argument to directory /tmp instead of removing it.
# Bumps old version in tmp to /tmp/$FILE+$stamp if it exists.
setenv stamp `date | awk '{print $2"_"$3"_"$4}'`
echo "Moving files(s) to the trash ..."
foreach FILE ($*)
if ( ! -f $FILE ) then # if not file or directory
if (! -d $FILE ) then
echo "$FILE not found"
exit
endif
endif
if (-f /tmp/$FILE) then
echo " * File /tmp/$FILE exists. "
echo " * Bump it to /tmp/$FILE+$stamp."
mv /tmp/$FILE /tmp/$FILE+$stamp
else if ( -d /tmp/$FILE) then
echo " * Directory /tmp/$FILE exists. "
echo " * Bump it to /tmp/$FILE+$stamp."
cp -r /tmp/$FILE /tmp/$FILE+$stamp
rm -r /tmp/$FILE
endif
mv $FILE /tmp
echo "$FILE moved to /tmp ..."
end
Mac OS X Hints
http://hints.macworld.com/article.php?story=20021018054958105