I have a basic inotifywait script called watch.sh and a few files ending in .styl in the same directory. Here’s the script, that catches the changes, but doesn’t execute the code within the do/done
I init it like sh watch.sh and here’s the script
#!/bin/sh
while inotifywait -m -o ./log.txt -e modify ./*.styl; do
stylus -c %f
done
I tried having echo "hi" within the exec portion but nothing executes
The problem you are having is with the
-moption forinotifywait. This causes the command to never exit. Sincewhilechecks the exit status of a command, the command must exit in order to continue execution of the loop.Here is the description of
-mfrom the manpage:Removing the
-moption should resolve your issues: