Back to the command reference

join

FilesAdvanced In simulator In real Linux

Join lines of two sorted files on a common field

Name: join: like a database JOIN

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

join merges lines of two files that share a common field, like a database JOIN. Both files must be sorted on that field first.

Syntax

join [OPTION]... FILE1 FILE2

Common options

-t CHARField separator
-1 FIELDJoin field of FILE1
-2 FIELDJoin field of FILE2
-a FILENUMAlso print the unpaired lines of file FILENUM (1 or 2)
-v FILENUMPrint only the unpaired lines of file FILENUM
-i / --ignore-caseIgnore case when comparing
-o FORMATChoose the output fields, e.g. -o 1.1,2.2

Examples

  • $ join -t, users.csv orders.csv

    Join two CSVs on their first field

    Explain

Related