Skip to content

Instantly share code, notes, and snippets.

@NatalieWolfe
Last active April 10, 2020 15:31
Show Gist options
  • Save NatalieWolfe/39c9aaa95c599434646c9ff9c5d17816 to your computer and use it in GitHub Desktop.
Save NatalieWolfe/39c9aaa95c599434646c9ff9c5d17816 to your computer and use it in GitHub Desktop.
Script to watch a directory for changes.
#!/bin/bash
# Usage: ./watch.sh watch_id path_to_watch
touch "/tmp/watch_${1}_1"
ls -x > "/tmp/watch_${1}_2"
cat "/tmp/watch_${1}_1" "/tmp/watch_${1}_2" | sort | uniq
mv "/tmp/watch_${1}_2" "/tmp/watch_${1}_1"
@abhaypatil87
Copy link

thanks!

@abhaypatil87
Copy link

#!/bin/bash
monitor() {
inotifywait -m ~ -e close export.dsv |
while read path action file; do
awk '{print "|"$0"|">"newexport.dsv"}' export.dsv;
done
}

monitor &

@NatalieWolfe
Copy link
Author

Nice. That is much better. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment