Cannot use awk pipe output
the function awk '!seen[$0]++' print the new occurrences in an input pipe.
I am however unable to add a pipe after. E.g
my_function_with_ouput | awk '!seen[$0]++' | while read j
do
echo $j
doneDoesn't produce any output.
11 Answer
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 ...