Linux paste Command: Join Corresponding Lines Side by Side
paste takes corresponding lines from multiple files and joins them side by side into a single line. The default delimiter is a tab, and it can also be used to turn vertically stacked values into a single line.
What is the paste command?
Unlike cat, which concatenates file contents vertically, paste matches the first lines together, the second lines together, and so on. If the file lengths differ, the shorter one is filled with empty fields.
Basic syntax
paste [option] [file...]
Installed implementations and options may vary depending on the distribution. Check the description on the current system with man paste.
Examples
Combine two files by columns
Attach the corresponding line from the second file next to each line of the first file.
paste names.txt scores.txt
Specify a delimiter
Use a colon instead of a tab to separate values from the two files.
paste -d ':' names.txt scores.txt
Changing one file into one row
-s reads the file continuously and joins the lines horizontally.
paste -s -d ',' names.txt
Combine lines of two inputs
This command places the first lines of two files side by side, and the second lines side by side, and so on. The example below does not create actual files because it uses process substitution in Bash.
paste -d, <(printf 'Ana\nBob\n') <(printf '7\n12\n')
Example output:
Ana,7 Bob,12
Unlike join, which matches rows by a common key, paste aligns lines by position. If one input has fewer lines, the missing fields are filled with empty values. In environments that do not support process substitution, such as POSIX-only shells, prepare the two inputs as temporary files.
Main Options and Format
| Options/Format | Description |
|---|---|
-d list |
Specifies the delimiter to use at the joining position. |
-s |
Combines lines from each file sequentially into one line. |
- |
Uses standard input in place of file arguments. |
Precautions when using
First, check whether the corresponding lines of two files refer to the same object. If the line order is different, incorrect values may be placed side by side without causing an error. If you need to join lines using a common key, check the sorting condition and then use join.
Frequently Asked Questions
What is the difference between paste and join?
paste attaches lines according to their line numbers, while join connects lines that have the same value in a common field.
Official Documentation
You can check the exact behavior of the options and the differences between implementations in the official documentation on paste.









