Skip to content

Instantly share code, notes, and snippets.

@DavidLutton
Last active June 7, 2017 12:48
Show Gist options
  • Save DavidLutton/a9836f6757a860a45812d926c53eea31 to your computer and use it in GitHub Desktop.
Save DavidLutton/a9836f6757a860a45812d926c53eea31 to your computer and use it in GitHub Desktop.
Find USB then rsync && sync && umount USB
#!/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