linux - 从标准输入读取粘贴命令

标签 linux shell paste

$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/

相关文章:

PHP fork,并从 child 那里得到结果

shell - 如何从 ld.so.cache 中删除条目?

linux - : ". [script]" or "source [script]", "bash [script] or $SHELL [script]"和 "./[script]"或 "[script]"有什么区别?

jquery - 从剪贴板粘贴

linux - Bash 多变量赋值

linux - uniq 终端命令不起作用?

linux - R 将 tcpdump 输出设置为 fifo 然后变量或连接

linux - 如何让这个 init.d 脚本在服务器重启时启动?

TinyMCE:paste_enable_default_filters 保留颜色、img 和字体大小

r - 如何在 R 中将字符串计算为变量?