在 Bash 中,管道tail -f到read循环会无限期地阻塞。
while read LINE0
do
echo "${LINE0}";
done < <( tail -n 3 -f /tmp/file0.txt | grep '.*' )
# hangs
Run Code Online (Sandbox Code Playgroud)
删除-for | grep '.*',然后循环将迭代。
以下就不会挂。
tail -n 3 -f /tmp/file0.txt | grep '.*'
Run Code Online (Sandbox Code Playgroud)
是什么导致了这种行为?
无论如何,Bash 是否可以跟踪文件并读取管道表达式?