Viewing and processing text

Command paste

Concatenate lines from multiple files

Linux · Bash examples · commands run on the selected server

When to use paste

Use paste to join corresponding text lines side by side or collapse lines into one record. Check that the input files have compatible ordering; this tool matches by line position, not by a key.

Syntax

paste [OPTIONS] [FILE...]

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

-d LIST
Use specified delimiters.
-s
Concatenate the lines of each file sequentially.
-
Read the corresponding column from standard input.

Usage examples

Merge Columns

paste ./names.txt ./values.txt

Each pair of lines is joined with a tab separator.

Join separated by commas

paste -d, ./names.txt ./values.txt

A comma replaces the default tab, but output is not automatically escaped as CSV.

Collect lines into one

paste -sd, ./names.txt

All input lines are combined into a single comma-separated line.

Notes and limitations

  • By default, lines are concatenated by tabs; The number of lines in the files may vary.
  • The utility does not escape special characters CSV.

Common questions and troubleshooting

Can paste join records by an ID column?

No. It combines line positions. Use join on appropriately prepared inputs or a structured data tool for key-based matching.

Why is the resulting comma-separated file invalid?

Embedded commas, quotes or newlines are not CSV-escaped automatically. Use a CSV writer when those characters are possible.

Further help

Options vary by version and distribution. Check the installed documentation with this command: man paste.