Home·Terminal commands

paste

Text processing

Usage

paste [file1] [file2]

Glues files together side by side with a tab between them; unlike join it matches lines by position and never looks at their content.

Common flags

FlagMeaning
-dWhich characters to put between the columns, used in turn
-sPut all lines of a file onto one line
-Read standard input, once for each column you want

Examples

paste names.txt scores.txt

The two files side by side, tab separated.

paste -sd, list.txt

Turns a list of lines into one comma-separated line.

paste - - < pairs.txt

Folds every two lines into one.

These were built to be piped together. Three joined commands are usually shorter than one that does everything.

How to read this

  • Square brackets [ ] mark a part you may leave out.
  • An ellipsis … means you can list more than one.
  • Flags are case-sensitive — in some commands -r and -R do different things.

Questions

Q. What does paste do?

Glues files together side by side with a tab between them; unlike join it matches lines by position and never looks at their content.

Q. How do I type it?

paste [file1] [file2] — square brackets mark the parts you can leave out.

Q. How many flags are worth knowing?

3 are listed here; the full set is in man paste. This command sits under Text processing.

Related commands

man page: man paste