Last active
June 7, 2017 12:48
-
-
Save DavidLutton/a9836f6757a860a45812d926c53eea31 to your computer and use it in GitHub Desktop.
Find USB then rsync && sync && umount USB
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
#!/bin/bash | |
# Use find to search for media matching USB* | |
# rsync *.pdf in current directory to media && sync && umount media | |
# Inform operator | |
while [ True ] | |
do | |
# echo -en "\a" # terminal tone (beep) | |
sleep .5 | |
res=$(find /media/$USER/ -type d -name 'USB*' | wc -l ) | |
echo -n "$res" | |
if [ $res -eq 1 ] | |
then | |
sleep .25 | |
find /media/$USER/ -type d -name "USB*" -print0 | while IFS= read -r -d $'\0' line; do | |
echo | |
rsync --delete --exclude="*.sh" -av . "$line"/ && sync && sudo umount "$line" && echo "Pass" || echo "Fail" | |
done | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment