要监视linux中的文件,我可以使用inotify工具,如下所示
#!/bin/bash
# with inotify-tools installed, watch for modification of file passed as first param
while inotifywait -e modify $1; do
# do something here
done但是我如何在OSX中实现这一点呢?
发布于 2013-03-28 06:19:24
如果您想将其封装到Python脚本中,您可以使用Watchdog,它可以与Linux和OSX一起使用。
https://pypi.python.org/pypi/watchdog
下面是用watchdog替换pyinotify的样子:
https://github.com/raphdg/baboon/commit/2c115da63dac16d0fbdc9b45067d0ab0960143ed
Watchdog还有一个名为watchmedo的外壳实用程序
watchmedo shell-command \
--patterns="*.py;*.txt" \
--recursive \
--command='echo "${watch_src_path}"' \
.发布于 2011-08-06 06:55:03
可以,您可以使用FSEvents API
发布于 2016-07-07 01:19:38
您可以使用entr工具。示例用法:
ls some_file | entr do_something在Mac上通过Brew安装:brew install entr。
https://stackoverflow.com/questions/6963423
复制相似问题