2011-08-05 9 views
6

のメソッドシェル、私はこのは、Linuxでファイルを監視するにはOSX

#!/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 

のようなのinotify-ツールを使用していますが、どのように私はOSXでこれを達成することができますか?

答えて

3

はい、あなたはPythonスクリプトにこれをラップする場合は、LinuxとOSXの両方で動作するウォッチドッグを使用することができますFSEvents API

+0

これはシェルスクリプトで使用できますか? –

+1

いいえ、しかし、Python用のラッパーライブラリがあります:http://pypi.python.org/pypi/MacFSEvents/0.2.4 – Baversjo

0

あなたはentrを使用することができますツール。使用例:

ls some_file | entr do_something 

Brew経由でインストールする:brew install entr

関連する問題