how to achieve linux's inotify-tools shell methods on osx

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 07:22:01
Peter Sankauskas

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 watchmedo:

watchmedo shell-command \
    --patterns="*.py;*.txt" \
    --recursive \
    --command='echo "${watch_src_path}"' \
    .
Baversjo

Yes, you can use the FSEvents API

You can use entr tool. Example usage:

ls some_file | entr do_something

On Mac install via Brew: brew install entr.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!