Last active
August 20, 2017 12:01
-
-
Save greyltc/dcfab85afb29bad4e476b973b2575315 to your computer and use it in GitHub Desktop.
uses rsync to send all files in a directory except for the ones that are open
This file contains hidden or 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
#!/usr/bin/env bash | |
#bash <(curl -L https://gist.github.com/greyltc/dcfab85afb29bad4e476b973b2575315/raw) $DEST | |
shopt -s nullglob | |
files=(*) | |
NOTOPEN=() | |
for i in "${!files[@]}"; do | |
if fuser -s "${files[$i]}" ; then | |
echo "${files[$i]} is open" | |
else | |
NOTOPEN+=(${files[$i]}) | |
fi | |
done | |
echo "Sending ${NOTOPEN[@]}..." | |
rsync -av --remove-source-files ${NOTOPEN[@]} $1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment