Skip to content

Instantly share code, notes, and snippets.

@toc21c
Created September 7, 2016 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toc21c/0338fdb6143af797d15f930b44aa9402 to your computer and use it in GitHub Desktop.
Save toc21c/0338fdb6143af797d15f930b44aa9402 to your computer and use it in GitHub Desktop.
rsync copy & remove folder
#!/usr/bin/env bash
if [ $# -ne 2 ]; then
echo "Usage: ${0##*/} SRC DEST"
exit
fi
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: ${0##*/} SRC DEST"
exit
fi
rsync -av --stats --progress --ignore-existing --remove-source-files "$1" "$2" && find "$1" -depth -type d -empty -exec rmdir {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment