paste

Linux · Text · reference only

What it does

Merges files line by line, placing each line of one file next to the line in the same position of the others.

Syntax

paste [opciones] [fichero...]

Options and parameters

  • -d lista

    Uses those characters as delimiters instead of a tab.

  • -s

    Joins all the lines of each file into a single one, instead of going file by file.

  • -z

    Uses the null character as the line separator.

  • -

    Reads from standard input; repeating it spreads the lines into columns.

Usage examples

  • paste nombres.txt edades.txt

    Joins each name with its age, separated by a tab.

  • paste -d: a.txt b.txt

    Same, but separated by a colon.

  • paste -sd, lista.txt

    Turns a file's lines into a single comma-separated line.

  • seq 6 | paste - - -

    Spreads the numbers 1 to 6 into two rows of three columns.

Notes and common mistakes

  • If one file has fewer lines than another, the missing columns are left empty.

Related commands