$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 doesn't "cat num | paste - -
" generate the output as:
1 1
2 2
3 3
4 4
Clearly, 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 pastes them to create the first line of output. Then it repeats.
The POSIX specification for paste
covers the point explicitly:
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 '-
'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With