Skip to content

Instantly share code, notes, and snippets.

@commanda
Last active May 18, 2016 01:02
Show Gist options
  • Save commanda/ff80c6b306f5fa8e25bf20c7292ab8a7 to your computer and use it in GitHub Desktop.
Save commanda/ff80c6b306f5fa8e25bf20c7292ab8a7 to your computer and use it in GitHub Desktop.
A bash script that moves the given file or directory into the Trash.
#!/bin/sh
TRASH="$HOME/.Trash/";
args=("$@");
for f in $args; do
base=$(basename $f);
if [ -e "$TRASH$base" ] ; then
TS=`date`;
mv -f $f "$TRASH/$base $TS";
else
mv -f $f "$TRASH/$base";
fi
done
# alias rm="echo Use 'del', or the full path i.e. '/bin/rm'"
@jpf
Copy link

jpf commented Apr 19, 2016

I like date +%s for these sorts of things, since it's short and doesn't have spaces that make some applications sad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment