Piping from grep to awk not working
It's probably output buffering from grep. you can disable that with grep --line-buffered
.
But you don't need to pipe output from grep into awk. awk can do regexp pattern matching all by itself.
tail -f test.txt | awk '/Beam/ {print $3}'
Using tail -f test.txt | awk '/Beam/{print $3}'
works for me. As well as using tail -f test.txt | grep --line-buffered Beam | awk '{print $3}'
(gnu grep).
The issue here is if awk
received the data line-by-line or as one larger data block. The GNU version of grep sends output in larger blocks since it is more efficient, but awk
needs to read line-by-line in order to output line-by-line.
Put this way: grep
will only send data when the buffer is filled, awk is waiting for that buffer to be filled, so it's sending out nothing.
See the --line-buffered
option of grep
.