I have two scripts emitting single string to log files periodically that I need to tail -f and combine side by side for which I am using paste. This works but I am unable to pipe the output to another tail -f so that I can get a continuous output of the two strings pasted side by side.
To illustrate / reproduce the problem, I have the following scripts:
p1.sh:
#!/bin/bash
i=0
while true
do
i=$((i+1))
sleep 4
echo "P1string$i" >> out1.log
done
p2.sh:
#!/bin/bash
i=0
while true
do
i=$((i+1))
sleep 4
echo "P2string$i" >> out2.log
done
I run them in the background like so:
$ ./p1.sh &
$ ./p2.sh &
Now, this works:
paste <(tail -f out1.log) <(tail -f out2.log)
But this does not work:
paste <(tail -f out1.log) <(tail -f out2.log) | tail -f
In principle, this is just piping stdout to tail -f and should work! no?
tail -f? The command you posted,paste <(tail -f out1.log) <(tail -f out2.log)does already exactly what you want. The problem I see in this approach is only, if one logfile is growing faster than the other, as paste will wait for a new line from each file.