I'm attempting to use part of a one-liner found here: Script to monitor folder for new files?

When I try the following procedure I get no output whatsoever and I cannot figure out why.

In terminal 1:

inotifywait -m ~/somefolder | awk '{ print $3; fflush() }' 

Then in terminal 2:

touch ~/somefolder/newfile

When not piping to awk, inotifywait lists all the expected events to stdout and has no problem redirecting to a file either. Awk also appears to work correctly independent of inotifywait on text piped to it structured like the output of inotifywait. Using the two together just doesn't work for me.


awk was an alias for mawk on my machine which didn't work. gawk, however, came through and worked as expected.

  • If changing the alias and using gawk instead of mawk worked, consider making your edit into an answer and accepting the answer.
    – George M
    Jan 26, 2013 at 18:07

1 Answer 1


As you have found out, mawk buffers its input, so you would probably see effects once your total notify messages have reached some k. The linked article suggests that mawk has a -Winteractive flag to disable it, but I am in position to check that.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .