monitor a file on mac os x

712 Views Asked by At

There are a lot of similar posts out there, but none that does exactly what I want: I want a simple script, that watches a folder on a Mac for changes and passes the filename of the modified file to command/script when changes are detected.

The tool inotifywait doesn't exist on a mac. Folder events or fswatch or watchdog seem to be getting close, but it turns out they only watch folders or only return the folder name. watchdog might be doing what I need, but I could only find commands like this

watchmedo shell-command --recursive --command='echo ${watch_src_path}' .

which again only passes the folder name in the variable watch_src_path. Does anyone know how to get it (or another program) to pass on the file name of the changed file?

1

There are 1 best solutions below

0
On

Even if the question is very old, it may be useful to other people looking for the same functionality. I wrote fsw exactly to fill this gap. fsw will give you the name of the changed paths and the type of change event.

Hope this helps.

Edited: fsw was merged with fswatch.