I have 4 UART devices and I want to watch their output concurrently. I use the following script to do this job:
# first kill the cat process from last run
killall -v cat
for i in `seq 0 3`; do
cat /dev/crbif0rb0c$(i}ttyS0 | grep . --line-buffered &
# cat /dev/crbif0rb0c$(i)ttyS0 &
done
But I get no output from this script, except many empty lines. When I remove the grep
stuff and use the second line in the for loop, I get a lot of outputs, but not readable since all outputs are messed up.
So my question is why there is no output (except empty lines) when I use grep? Or anyone can provide a better (and workable) solutions for my scenario?
Thanks in advance!
[UPDATE] I suddenly found that cat /dev/crbif0rb0c${i}ttyS0 | grep ^ --line-buffered &
will work. Don't know why...