【发布时间】:2012-09-04 14:36:41
【问题描述】:
我特别想在 2 个子目录中同时查看 2 个不同的文件类型:
“js”子目录中的.coffee 文件类型
'css' 子目录中的 .styl 文件类型
我只知道这么多 bash,我正试图让这样的东西发挥作用
while inotifywait --format %w%f ./{css,js}/*.{styl,coffee}; do
# regex pattern to match the file ending
# and define it to $ending
if[ $ending == coffee ]
then
coffee -c $file
elif[ $ending == styl ]
then
stylus -c $file
fi
done
// 编辑 //
修改了这一行:
while inotifywait --format %w%f ./{css,js}/*.{styl,coffee}; do
所以现在它会检查这两个文件,但是如果 css 文件夹中没有 .coffee 文件,或者 js 中没有 .styl 文件,它会返回未找到文件的错误。
另外我注意到,当我运行这个脚本时,它会返回/运行以下 3 次
Setting up watches.
Watches established.
./css/styles.styl
【问题讨论】:
-
inotifywait 使用 POSIX 扩展正则表达式,并且受到限制:stackoverflow.com/questions/7943528/… 只需将这些脚本分开:每个咖啡/js 一个,每个 styl/css 一个
标签: regex bash inotify watch inotify-tools