News for hackers. Stuff that matters.
Re:Watch – A Useful Linux Command You May Have Never Heard Of by imurray on Tuesday October 26, 2010 @10:42AM (#1834353)
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 The webpage about it is here: 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/

Re:Watch – A Useful Linux Command You May Have Never Heard Of by jballanc on Wednesday October 27, 2010 @05:17AM (#1837865)
You can do something similar on OS X using Kicker (http://github.com/alloy/kicker), which is based on the FSEvents library.
Re:Watch – A Useful Linux Command You May Have Never Heard Of by JoeAltmaier on Tuesday October 26, 2010 @12:05PM (#1834726)
Much better, because its doesn't keep spamming you even when nothing has changed so far.
Re:Watch – A Useful Linux Command You May Have Never Heard Of by nitrogen on Tuesday October 26, 2010 @03:03PM (#1835552)
I 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.
Re:Watch – A Useful Linux Command You May Have Never Heard Of by konad on Wednesday October 27, 2010 @06:18AM (#1837983)
Or just let the kernel tell you via inotify http://en.wikipedia.org/wiki/Inotify
Re:Watch – A Useful Linux Command You May Have Never Heard Of by imurray on Wednesday October 27, 2010 @06:32AM (#1838010)
Sort 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.