$paste num let
1 a
2 b
3 c
4 d
所以当我这样做的时候
$ cat num | paste - -
1 2
3 4
我的问题是为什么“cat num | paste - -
”不生成如下输出:
1 1
2 2
3 3
4 4
最佳答案
显然,paste
从第一个"file"(标准输入)读取一行,然后从第二个"file"(也是标准输入)读取一行并将它们粘贴到创建第一行输出。然后重复。
paste
的 POSIX 规范明确地涵盖了这一点:
If '
-
' is specified for one or more of the files, the standard input shall be used; the standard input shall be read one line at a time, circularly, for each instance of '-
'.
关于linux - 从标准输入读取粘贴命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26480004/