Linux Standard Command Line Paste

$paste num let
1    a
2    b
3    c
4    d

      

So when I do

$ cat num | paste - - 
1    2
3    4

      

My question is why is " cat num | paste - -

" generating output like:

1     1
2     2
3     3
4     4

      

+3


source to share


2 answers


Clearly, it paste

reads a line from the first "file" (which is standard input) and then a line from the second "file" (which is also standard input) and inserts them to create the first line of output. Then it repeats.

The POSIX specification paste

explicitly states the dot:



If " -

" is specified for one or more files , standard input is used; standard input should be read one line at a time, circular, for each instance of " -

".

+6


source


You can use " paste num num

" to generate



1 1
2 2
3 3
4 4

      

-1


source







All Articles