如何使用FSWatch在Mac OSX上观看文件更改? [英] How to watch file changes on Mac OSX using FSWatch?

查看:370
本文介绍了如何使用FSWatch在Mac OSX上观看文件更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 fswatch 来从linux bash脚本中转换以下行,以便能够在Mac OSX上运行它:

I'm trying to use fswatch to translate the following lines from a linux bash script to be able to run it on Mac OSX:

inotifywait -r -m 'myfolder/' | while read MODFILE
do
    echo "something"
done

由于inotifywait在Mac OSX上不起作用,因此我想用第一行替换 FSWatch .尽管README引用了fswatch手册页,但它没有提供指向它的链接,并且在Internet上进行搜索都无法给我任何帮助.所以我试了一下.

Since inotifywait doesn't work on Mac OSX I want to substitute the first line for FSWatch. Although the README refers to the fswatch man page, it doesn't provide a link to it and a search around the internet doesn't get me anything. So I tried messing around a bit.

我创建了一个名为testfswatch/的文件夹,并尝试在父文件夹中运行以下命令,然后在testfswatch/文件夹中添加和更改文件:

I created a folder called testfswatch/ and I tried running the following commands in the parent folder and then adding and changing files on the testfswatch/ folder:

fswatch -o testfswatch/ | echo "LALA"
fswatch -o testfswatch/ | someSimpleProgram
fswatch -o testfswatch/ | xargs -n1 -I{} echo "LALA"
fswatch -o testfswatch/ | xargs -n1 -I{} ./someExecutable
fswatch -o testfswatch/ | xargs -n1 echo "LALA"
fswatch -o testfswatch/ | xargs -n1 someExecutable
// And more variations of the above

当我更改或添加tesfswatch/文件夹中的文件时,这些命令似乎都不起作用.

None of these commands seem to do anything when I change or add files in the tesfswatch/ folder though.

有人知道我在做什么错吗?欢迎所有提示!

Does anybody know what I'm doing wrong here? All tips are welcome!

推荐答案

fswatch的1.0之前版本使用的调用语法与1.0和更高版本相比略有不同. 确保您运行的版本晚于1.0,如果您的版本早于该版本,则可能要升级.

pre-1.0 versions of fswatch use a slightly different invocation syntax, compared to 1.0 and later. Make sure that you're running a version later than 1.0, You may want to upgrade if your version is older than that.

这篇关于如何使用FSWatch在Mac OSX上观看文件更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆