I am facing an issue today with awk command and data stream using fifo under ubuntu 14.04.
I have a writer.sh providing data
#!/bin/bash
PIPE_NAME="pipe.fifo"
DATA="dataA,dataB"
# create fifo if doesn't exist
if ! [ -p "$PIPE_NAME" ]; then
mkfifo $PIPE_NAME
fi
# keep fifo openned
sleep 10000 > $PIPE_NAME &
while [[ true ]];
do
echo $DATA > $PIPE_NAME
sleep 1
done
which is working fine.
On another shell, if i write the command:
cat pipe.fifo|grep data|awk -F, '{print $1}'
I don't get anything.
I've tried creating a dataList.txt file with the following content:
dataA,dataB
dataA,dataB
dataA,dataB
The following command:
cat dataList.txt|grep data|awk -F, '{print $1}'
produces the expected result:
dataA
dataA
dataA
Note: The grep command doesn't have any interest here but in my application, it is useful to get only data matching a certain pattern.
Do you have any idea of what I misunderstand ?