Created
March 1, 2013 11:32
-
-
Save michitux/5064086 to your computer and use it in GitHub Desktop.
Simple script for executing a command whenever a file in the current directory (or a subdirectory of it) that matches a certain expression (using grep) is changed. The script uses inotifywait (from inotify-tools), i.e. it waits efficiently using inotify. The rationale for watching the whole directory is that editors like VIM work with temporary …
This file contains hidden or 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 | |
command="$1" | |
expression="$2" | |
$command | |
inotifywait -r -m --format '%f' -e close_write "$PWD" | while read file; do | |
if echo "$file" | grep "$expression"; then | |
$command | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment