Cannot use awk pipe output
awk
buffers the STDOUT stream, you need to flush the STDOUT, make it flush the stream using the fflush()
function of GNU awk
:
my_function_with_ouput | awk '!seen[$0]++ {print; fflush()}' | while ...
If you don't have gawk
, take help from stdbuf
, unbuffered STDOUT:
my_function_with_ouput | stdbuf -o0 awk '!seen[$0]++' | while ...
or make STDOUT line buffered:
my_function_with_ouput | stdbuf -oL awk '!seen[$0]++' | while ...