Search notes:

Shell command: paste

Without command line options

paste file-1 file-2 … file-n
Without command line options, paste will read one line from each file and write each line, without new line, but separated by a tabulator. It will do that until the all lines are read.
So, if file_one contains
foo
bar
baz
and file_two contains
one
two
three
then paste file_one file_two will print
foo       one
bar       two
baz       three
This behavior is somewhat similar to that obtained with the shell command pr -mt … or with positional joins in DuckDB.

-d delimiter

-d specifies one or more delimiters (instead of the default tabulator) with which the lines will be pasted.
paste -d, file_one file_two will print
foo,one
bar,two
baz,three

-s don't read files in parallel

-s can be used to create a pivot from a file.
If some.txt contains
foo
10.3
18.9
17.1
bar
7.8
12.7
15.6
baz
11.4
15.1
16.4
then paste -d "\t\t\t\n" some.txt will print
foo	10.3	18.9	17.1
bar	7.8	12.7	15.6
baz	11.4	15.1	16.4
Note how each delimiter is used in sequence and then «recycled».

Examples

seq 10 | paste -sd+ | bc
calculates the sum of the first 10 integers: it will print 55.

See also

Shell commands
The R function paste and the Python function zip.

Links

https://github.com/ReneNyffenegger/shell-commands/tree/master/paste

Index