我在同一目录中有一个名为watch.sh的基本inotifywait脚本和一些以.styl结尾的文件。下面是脚本,它捕获更改,但不在do/do中执行代码
我像sh watch.sh一样初始化它,下面是脚本
#!/bin/sh
while inotifywait -m -o ./log.txt -e modify ./*.styl; do
stylus -c %f
done我尝试在exec部分中使用echo "hi",但没有执行任何内容
发布于 2012-09-07 05:48:43
您遇到的问题与inotifywait的-m选项有关。这会导致该命令永远不会退出。由于while会检查命令的退出状态,因此命令必须退出才能继续执行循环。
以下是手册页中对-m的描述:
Instead of exiting after receiving a single event, execute
indefinitely. The default behaviour is to exit after the first
event occurs.删除-m选项应该可以解决您的问题:
while inotifywait -o ./log.txt -e modify ./*.styl; do
stylus -c %f
done发布于 2014-10-20 22:02:49
试试这个:
while K=`inotifywait -o ./log.txt --format %f -e modify ./*.styl`;
do
stylus -c $K;
donehttps://stackoverflow.com/questions/12308761
复制相似问题