Skip to content

Instantly share code, notes, and snippets.

@iamshreeram
Created October 23, 2020 07:39
Show Gist options
  • Save iamshreeram/4f7a6ebb3466965f2f95ce986c979f5f to your computer and use it in GitHub Desktop.
Save iamshreeram/4f7a6ebb3466965f2f95ce986c979f5f to your computer and use it in GitHub Desktop.
Live monitor for any new file creation and copy them to destn location : Used for write-only back-up for new files
srcdir="/tmp"; inotifywait -e close_write --format "%f" --monitor $srcdir |
while IFS= read -r line
do
echo $line
cp "$srcdir/$line" . #this would not replicate directories
# tar cf - "$line" | tar -C destination/ xf - #this should replicate directories
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment