Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

EDIT:

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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.