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?
Asked by Ketan
(9426 rep)
Aug 11, 2023, 05:52 PM
Last activity: Aug 12, 2023, 03:22 AM
Last activity: Aug 12, 2023, 03:22 AM