Perhaps the best thus far

It’s been a while since fsniper, and even longer since entr. Here’s, which also watches files for changes, and then executes a command.

It’s a little difficult to show, so you might have to use your imagination. There are several ways to cue it; in my test runs, this:

./ test.txt cat test.txt

was enough to refresh the screen with my edits, when I saved test.txt back to disk from another terminal window.

That’s not the only way to use, and the help flags will give you ideas on other methods. For example, you can monitor the output of a second command, and when that changes, execute a third command.

I like a lot better than either fsniper or entr. fsniper was a bit more complex, and in the end, didn’t quite work. entr, on the other hand, worked fine, but expected to receive updates through a pipe, which is a tiny bit clunky.

But is very straightforward and very flexible, and does what it promises. And I like that the task is reduced to an easily dissected script, rather than complex code.

So my advice, if you have to pick one of the three, is to go with Unless of course, you have another method you prefer. 😉

3 thoughts on “ Perhaps the best thus far

  1. valadil

    It’s a little clunky but I prefer inotifywait/inotifywatch, which watches a file or directory and responds to changes you’ve specified.

    My general workflow for watching a changing file is
    while : ; do
    inotifywait /path/to/file -e MODIFY
    do stuff

    inotifywait pauses until a flie is modified. Then stuff can happen. If you want stuff to be more interesting, capture the output of inotifywait and parse out the file name.

  2. Pingback: wendy: Under wendy’s watchful eye | Inconsolation

  3. Pingback: inotifywait, inotifywatch and incron: A package deal | Inconsolation

Comments are closed.