\cat unix
Did you ever accidentally delete important files? I did, so I made a small script to replace /bin/rm with. Askrm shows you the list of to-be-deleted files and annoyingly asks you if you really want to delete them. I didn't like this kind of annoying confirmation, but I decided to get used to it after blowing away my precious research files.
Why not just alias rm='/bin/rm -vi' or alias rm='/bin/rm -vI'? First, the -f option overrides any previous -i options, so rm -rf please_dont_delete_me will successfully do its job without bothering asking you. Second, the -I option is not enough because it asks you only once and I already know what I usually do when asked. Just press "y" no matter what I typed and then "Oooooops!" CTRL+C. Askrm also asks only once, but it requires you to enter "Y" not just "y" and shows all the files you specified to give you the last chance for careful review.
OK, then here we go. Use alias to replace /bin/rm with askrm: alias rm=askrm.
#!/bin/sh # askrm shows all the files you specified and asks you if you really want to # delete them. # (C) 2007 GPL by Huidae Cho <http://geni.ath.cx> if [ $# -eq 0 ]; then rm exit fi rm_opt= for i do case "$i" in -[^-]*) rm_opt="$rm_opt $i" shift ;; --) rm_opt="$rm_opt $i" shift break ;; *) break ;; esac done if [ $# -eq 0 ]; then rm $rm_opt exit fi for i do if [ -e "$i" ]; then find -f "$i" # You may want to remove the -f option in Linux. else echo "rm: $i: No such file or directory" fi done | less -F echo echo "YOU'RE IN `pwd`." echo -n "DELETE THE FILES LISTED ABOVE? (Y/N) " read yn if [ "$yn" = "Y" ]; then rm -v $rm_opt "$@" else echo "NOT DELETED!" fi