Using inotifywait
to watch for file changes recursively in the current directory. I use $CHECK
to ignore unwanted directories and filetypes.
#!/bin/bash
inotifywait -r -e close_write,moved_to,create -m . |
while read -r DIR EVENT FILE; do
CHECK="$( echo "${DIR}${FILE}" | egrep -v '^\./(\.git|\.sass-cache|node_modules|public|static)' | egrep -v '\.(tmp|css)$' )"
if [ "$CHECK" ]; then
echo "Change in ${DIR}${FILE}"
# This is what gets run
make dev
fi
done
Install inotify-tools
on both Debian and CentOS.