Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
If changing the alias and using gawk instead of mawk worked, consider making your edit into an answer and accepting the answer. – uther Jan 26 '13 at 18:07
up vote 0 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.