Last active
October 19, 2019 21:51
-
-
Save thewrongjames/be3f7a17f66dbfe9633a1465769ae306 to your computer and use it in GitHub Desktop.
Run a command on a file every time it changes, using inotifywait.
This file contains 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 | |
if [ $# -ne 2 ]; then | |
echo Run a given command on a file when it is modified. | |
echo Usage: runonfileonchange command file | |
exit 1 | |
fi | |
while inotifywait -e modify $2; do | |
$1 $2 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment