|  About Me  |  Blogs  |  Photos  |  Publications  |  Resume  | 

Safe rm

Surprise surprise! I installed a script to move things to trash when I
run rm. Here’s the script:

#!/bin/bash
#
# A tiny script that moves files to a wastebasket, rather than deleting them.
#
[ -d ~/.deleted ]
if [ $? -eq 1 ];
    then
        echo "Creating directory."
        mkdir ~/.deleted;
fi

for file in $@
    do
        mv $file ~/.deleted/
    done

I’ve aliased it to rm in .bashrc when I’m
running in interactive mode.

Leave a Reply

You must be logged in to post a comment.