Skip to content

Instantly share code, notes, and snippets.

@phamduchongan93
Last active November 5, 2019 01:07
Show Gist options
  • Save phamduchongan93/7b871348b607f677785c557bfc7f950e to your computer and use it in GitHub Desktop.
Save phamduchongan93/7b871348b607f677785c557bfc7f950e to your computer and use it in GitHub Desktop.
Update rm command for linux
function move_to_trash () {
# check if you have the backup directory.
if [ -d "/home/`whoami`/backup/" ]; then
mkdir -p "/home/`whoami`/backup/";
fi
# copy the files or folders before deleting it.
cp -r "$@" "/home/`whoami`/backup/" && command rm -rf "$@" && echo "Moved to trash";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment