Created
July 5, 2013 20:02
-
-
Save sksavant/5936876 to your computer and use it in GitHub Desktop.
Trashit
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
#!/bin/sh | |
# trashit | |
# original script | |
# http://www.macosxhints.com/article.php?story=20030217172653485 | |
# author: Shane Celis <shane (at) gnufoo (dot) org> | |
# | |
# Sun, 20-May-2007; 06:47:22 | |
# minor changes... | |
if [ $# -eq 0 ]; then | |
echo "usage: trashit <files...>" >&2 | |
exit 2; | |
fi | |
for file in "$@"; do | |
# get just file name | |
destfile="`basename \"$file\"`" | |
suffix=''; | |
i=0; | |
# If that file already exists, change the name | |
while [ -e "$HOME/.Trash/${destfile}${suffix}" ]; do | |
suffix=" - copy $i"; | |
i=`expr $i + 1` | |
done | |
mv -vi "$file" "$HOME/.Trash/${destfile}${suffix}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment