4 ms·
How many times did I want to watch a directory waiting for a file to appear in it? For this sort of thing I use a simple perl script called atchange. I could d
by imurray 16y ago
How many times did I want to watch a directory waiting for a file to appear in it?
For this sort of thing I use a simple perl script called atchange. I could do:
atchange . ls
And I'd see list output whenever a new file appeared in the directory. The hacky thing I usually use it for:
atchange my_source_file make
to make things rebuild when I save my_source_file in my editor.
The script is here: http://www.ccrnp.ncifcrf.gov/~toms/ftp/atchange http://www.ccrnp.ncifcrf.gov/~toms/ftp/atchange
The webpage about it is here: http://www-lmmb.ncifcrf.gov/~toms/atchange.html http://www-lmmb.ncifcrf.gov/~toms/atchange.html
I first learnt about it years ago while reading the entertaining ``Work'' Columns by Jeffreys Copeland & Haemer: http://alumnus.caltech.edu/~copeland/work/ http://alumnus.caltech.edu/~copeland/work/
- JoeAltmaier 16y agoMuch better, because its doesn't keep spamming you even when nothing has changed so far.
- nitrogen 16y agoI was thinking you could pipe watch into uniq, but then you wouldn't get any results until you killed it. The hexdump utility has adjacent duplicate line detection, and something similar would be trivial to create.
- jballanc 16y agoYou can do something similar on OS X using Kicker (http://github.com/alloy/kicker http://github.com/alloy/kicker), which is based on the FSEvents library.
- konad 16y agoOr just let the kernel tell you via inotify http://en.wikipedia.org/wiki/Inotify http://en.wikipedia.org/wiki/Inotify
- imurray 16y agoSort of, on Linux. See my comments elsewhere on this page for an inotify "replacement" of atchange, and notes on why it won't do quite the same thing as the perl script.