小编Eri*_*son的帖子

Bash tail -f 带有 while-read 和管道挂起

在 Bash 中,管道tail -fread循环会无限期地阻塞。

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 是否可以跟踪文件并读取管道表达式?

bash pipe tail

4
推荐指数
1
解决办法
8712
查看次数

标签 统计

bash ×1

pipe ×1

tail ×1