Created
January 5, 2021 21:06
-
-
Save iuriguilherme/f726df0f00917c5b0715112125a0935b to your computer and use it in GitHub Desktop.
Move files safely across filesystems
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/bash | |
## This script will move safely all files and folders in the arguments list to the last argument. It uses rsync so it can be sent to remote servers. | |
rsync -avvhSP --remove-source-files "$@" | |
for DIR in "${@}" | |
do | |
## like `rmdir` but recursively for every argument (only removes empty directories) | |
find "${DIR}" -type d -empty -delete | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment