如何在OSX上实现Linux的Inotify-Tools shell方法

问题描述 投票:0回答:3
要在Linux中监视文件,我可以使用诸如this

的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中实现这一目标?
    

file macos watch inotify-tools
3个回答
6
投票

https://pypi.python.org/pypi/watchdog

在这里,用看门狗替换pyinotify是什么样的:

https://github.com/raphdg/baboon/commit/2c115da63dac16d0fbdc9b45067d0ab0960143ed

watchDog还具有一个名为watchmedo

的外壳实用程序

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

是的,您可以使用

3
投票

您可以使用


0
投票

工具。示例用法:

ls some_file | entr do_something
Mac安装通过Brew:brew install entr

.
    

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.