Created
May 18, 2011 17:23
-
-
Save tomykaira/979056 to your computer and use it in GitHub Desktop.
Move multiple files to a directory with rm, instead of deletion. Some similar codes are not supporting mutiple file input, but this supports.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function my-trash(){ | |
while [ $# -ne 0 ]; do | |
if [ -a $1 ]; then | |
FULLPATH=$(cd $(dirname $1) && pwd)/$(basename $1) | |
if [[ $FULLPATH == /mnt/* || $1 == *~ || $(basename $1) == \#*\# ]]; then | |
\rm $FULLPATH | |
else | |
\mv $FULLPATH ~/.Trash | |
fi | |
case $? in | |
0 ) shift ;; | |
* ) echo "Failed to move" $1; return 1;; | |
esac | |
fi | |
done | |
return 0 | |
} | |
alias rm=my-trash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated not to cache temporary files.