Skip to content

Instantly share code, notes, and snippets.

@rogersguedes
Created May 7, 2020 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogersguedes/dc3440e4df588e0964df1b5e891dcf86 to your computer and use it in GitHub Desktop.
Save rogersguedes/dc3440e4df588e0964df1b5e891dcf86 to your computer and use it in GitHub Desktop.
sample script that shows how to use `inotifywait` result in a shell script.
#!/bin/sh
# Thanks to https://unix.stackexchange.com/questions/24952/script-to-monitor-folder-for-new-files
inotifywait -m . -e create -e moved_to |
while read dir action file; do
echo "The file '$file' appeared in directory '$dir' via '$action'"
# do something with the file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment