rm Command Replacement Using a Trash Folder
January 10, 2005
This is just a simple script that you can use to move things to a trash folder instead of really deleting it. Name it something like trash and put it in ~/bin. Now, use trash instead of rm.
#!/bin/bash # # This is an rm replacement to use a trash folder. # if [ ! -d $HOME/.junk ] then mkdir $HOME/.junk fi case $1 in -l) ls -l $HOME/.junk ;; -p) rm $HOME/.junk/* ;; *) for VAR in $* do mv $VAR $HOME/.junk/$VAR done esac