如何在osx上实现linux的inotify-tools shell方法 [英] how to achieve linux's inotify-tools shell methods on osx
问题描述
要监视linux中的文件,我可以使用类似inotify-tools
#!/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中实现这一目标?
如果要将其包装到Python脚本中,则可以使用可在Linux和OSX上使用的Watchdog.
https://pypi.python.org/pypi/watchdog
这是用看门狗替换pyinotify的样子:
https://github.com/raphdg/baboon/commit/2c115da63dac16d0fbdc9b45067d0ab0960143ed/p>
Watchdog还具有一个名为 To monitor a file in linux, I can use inotify-tools like this but how would I achieve this in OSX? If you want to wrap this into a Python script, you can use Watchdog, which works with both Linux and OSX. https://pypi.python.org/pypi/watchdog Here is what it looks like to replace pyinotify with watchdog: https://github.com/raphdg/baboon/commit/2c115da63dac16d0fbdc9b45067d0ab0960143ed Watchdog also has a shell utility called
这篇关于如何在osx上实现linux的inotify-tools shell方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!watchmedo
的shell实用程序:watchmedo shell-command \
--patterns="*.py;*.txt" \
--recursive \
--command='echo "${watch_src_path}"' \
.
#!/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
watchmedo
:watchmedo shell-command \
--patterns="*.py;*.txt" \
--recursive \
--command='echo "${watch_src_path}"' \
.