Text
paste
Merge lines from files side by side.
textcolumnsmergefilesjoin
Additional Notes
paste merges lines from multiple files, writing them side by side with a tab between columns. It is the inverse of cut and a quick way to build tables from separate column files.
When given one file, paste places one input line per output line with a chosen delimiter. Use - to read one column from standard input.
Syntax
paste [options] [file ...]
Parameters
options: Flags that change the delimiter or mode.file: One or more files to merge (use-for standard input).
Common Options
-d LIST,--delimiters=LIST: Use characters from LIST as column separators (cycled per column).-s,--serial: Paste one file at a time, its lines becoming one output row.-z: Lines end with NUL instead of newline.
Examples
paste first.txt second.txt
Join the two files as two side-by-side columns separated by tabs.
paste -d, a.txt b.txt c.txt
Merge three files using commas as the column separator.
ls | paste - - -
Read three items per row from standard input.
paste -s -d, numbers.txt
Turn one file's lines into a single comma-separated row.
cut -d: -f1 /etc/passwd | paste -d, - names2.txt
Combine a column from a file with a stdin column.
Practical Notes
- The default column separator is a tab; change it with
-d. -sis useful for turning a vertical list into a horizontal one.pastepairs naturally withcutandcolumnfor table building.- When inputs have different line counts, shorter columns simply stop early.