fswatchを使用して、ファイルが変更されたときにいくつかのアクションを実行します。次のコマンドを使用します。
fswatch -o -r '.' | while read MODFILE
do
echo 'Some file changed, so take some action'
done
いくつかのファイルを変更すると、ターミナルに次のように表示されます。
Some file changed, so take some action
Some file changed, so take some action
Some file changed, so take some action
etc.
しかし、どのファイルが実際にアクションを引き起こしたのかも疑問です。そこで、fswatch の man ページを確認したところ、次のように表示されました。
fswatch writes a record for each event it receives containing:
- The timestamp when the event was received (optionally).
- The path affected by the current event.
- A space-separated list of event types (see EVENT TYPES ).
しかし、言ったように、端末に何もリストされていません。「現在のイベントの影響を受けるパス」を表示する方法を知っている人はいますか?
すべてのヒントは大歓迎です!