Bash: execute script while saving file?

I would like to use Bash to automatically run a test suite when I save any file in a given directory.

Is there a mechanism for Bash to execute a given script to save events?

Thank.

:: EDIT ::

I should have mentioned that I use OSX.

+5
source share
4 answers

: (OP) , OSX. - OSX. ( BSD) " kqueue", - . Apple " Watcher", , .

Qaru ( ).

- , , , . , , ...

, Linux , :

Linux, inotify. , inotify-tools, inotifywait.

, , , , . inotifywait , , , :

while :; do
    inotifywait -e modify /some/directory
    run_test_suite
done

, (, Python tdaemon, ).

+5

incron, , .

0

dnotify , inotify (linux kernel < 2.6.13).

dnotify - linux :

http://en.wikipedia.org/wiki/Dnotify

. dir :


dnotify WATCH_DIR -M -e SCRIPT_TO_EXECUTE

, SCRIPT_TO_EXECUTE , WATCH_DIR.

0

inotify, : Inotify C

0

All Articles