Unix & Linux Asked by Eric Larson on November 23, 2021
In Bash, piping tail -f
to a read
loop blocks indefinitely.
while read LINE0
do
echo "${LINE0}";
done < <( tail -n 3 -f /tmp/file0.txt | grep '.*' )
# hangs
Remove the -f
or | grep '.*'
, then the loop will iterate.
The following does not hang.
tail -n 3 -f /tmp/file0.txt | grep '.*'
What causes this behavior?
Is there anyway in Bash to follow a file and read in a pipe expression?
tail -n 3 -f /tmp/file0.txt | grep --line-buffered '.*' | while read LINE0
do
echo "${LINE0}";
done
Answered by Ipor Sircer on November 23, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP