manpagez: man pages & more
info coreutils
Home | html | info | man

File: coreutils.info,  Node: join invocation,  Prev: paste invocation,  Up: Operating on fields

8.3 ‘join’: Join lines on a common field
========================================

‘join’ writes to standard output a line for each pair of input lines
that have identical join fields.  Synopsis:

     join [OPTION]... FILE1 FILE2

   Either FILE1 or FILE2 (but not both) can be ‘-’, meaning standard
input.  FILE1 and FILE2 should be sorted on the join fields.

     $ cat file1
     a 1
     b 2
     e 5

     $ cat file2
     a X
     e Y
     f Z

     $ join file1 file2
     a 1 X
     e 5 Y

‘join’’s default behavior (when no options are given):
   • the join field is the first field in each line;
   • fields in the input are separated by one or more blanks, with
     leading blanks on the line ignored;
   • fields in the output are separated by a space;
   • each output line consists of the join field, the remaining fields
     from FILE1, then the remaining fields from FILE2.

* Menu:

* General options in join::      Options which affect general program behavior.
* Sorting files for join::       Using ‘sort’ before ‘join’.
* Working with fields::          Joining on different fields.
* Paired and unpaired lines::    Controlling ‘join’’s field matching.
* Header lines::                 Working with header lines in files.
* Set operations::               Union, Intersection and Difference of files.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.