Bash T形三通>;(n类)<;tmpfile在重复之前完全打印tmpfile

Bash T形三通>;(n类)<;tmpfile在重复之前完全打印tmpfile,bash,process-substitution,Bash,Process Substitution,tmpfile包含以下内容: a b c d [me@localhost somedir]$ tee >(cat -n) < tmpfile a b c d [me@localhost somedir]$ 1 a 2 b 3 c 4 d 问题标题中的命令输出如下: a b c d [me@localhost somedir]$ tee >(cat -n) < tmpfile a b c d [me@lo

tmpfile包含以下内容:

a
b
c
d
[me@localhost somedir]$ tee >(cat -n) < tmpfile    
a
b
c
d
[me@localhost somedir]$      1  a
     2  b
     3  c
     4  d
问题标题中的命令输出如下:

a
b
c
d
[me@localhost somedir]$ tee >(cat -n) < tmpfile    
a
b
c
d
[me@localhost somedir]$      1  a
     2  b
     3  c
     4  d
[me@localhostsomedir]$tee>(类别n)
由于tee和cat是通过命名管道连接的,所以我希望cat在tee打印下一行之前将输出发送到终端。大概是这样的:

[me@localhost somedir]$ tee >(cat -n) < tmpfile    
a
1  a
b
2  b
c
3  c
d
4  d
[me@localhost somedir]$     
[me@localhostsomedir]$tee>(类别n)
有人能解释一下这里发生了什么事吗?我考虑了比赛条件的可能性,tee刚刚获胜,但这种情况也发生在大小等于几KBs的文件中。我觉得这里有更多的东西


谢谢。

如果你想让对方赢,你可以轻松做到(假设我们使用的是相同的
tee
实现,因为具体的顺序是实现定义的,而不是标准化的):

#请注意,这使用了bash 4.1中添加的自动FD分配支持

(exec{orig_stdout}>&1;{tee>(cat>&$orig_stdout)| cat-n;}如果你想做出关于“完全”的断言,你需要使用更大的输入。几KB是很小的。谢谢@Charles。这是很多好的信息。我正在慢慢地消化它。你上次的编辑让事情更清楚了。