The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
<html><head><title>join</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" >
</head>
<body class='pod'>
<!--
  generated by Pod::Simple::HTML v3.01,
  using Pod::Simple::PullParser v2.02,
  under Perl v5.008002 at Thu Aug  5 13:56:32 2004 GMT.

 If you want to change this HTML document, you probably shouldn't do that
   by changing it directly.  Instead, see about changing the calling options
   to Pod::Simple::HTML, and/or subclassing Pod::Simple::HTML,
   then reconverting this document from the Pod source.
   When in doubt, email the author of Pod::Simple::HTML for advice.
   See 'perldoc Pod::Simple::HTML' for more info.

-->

<!-- start doc -->
<a name='___top' class='dummyTopAnchor' ></a>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="NAME"
>NAME</a></h1>

<p>join - relational database operator</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="SYNOPSIS"
>SYNOPSIS</a></h1>

<p>join [<b>-a</b> <i>file_number</i> | <b>-v</b> <i>file_number</i>] [<b>-e</b> <i>string</i>] [<b>-o</b> <i>list</i>] [<b>-t</b> <i>char</i>] [<b>-1</b> <i>field</i>] [<b>-2</b> <i>field</i>] <i>file1</i> <i>file2</i></p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="DESCRIPTION"
>DESCRIPTION</a></h1>

<p>The <b>join</b> utility performs an ``equality join&#39;&#39; on the specified files and writes the result to the standard output.
The ``join field&#39;&#39; is the field in each file by which the files are compared.
The first field in each line is used by default.
There is one line in the output for each pair of lines in <i>file1</i> and <i>file2</i> which have identical join fields.
Each output line consists of the join field,
the remaining fields from <i>file1</i> and then the remaining fields from <i>file2</i>.</p>

<p>The defaults are: 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 <i>file1</i>,
then the remaining fields from <i>file2</i>.</p>

<p>Many of the options use file and field numbers.
Both file numbers and field numbers are 1 based,
i.e.
the first file on the command line is file number 1 and the first field is field number 1.
The following options are available:</p>

<dl>
<dt><a name="-a_file_number"
><b>-a</b> <i>file_number</i></a></dt><p class="pad"></p>

<dd>In addition to the default output,
produce a line for each unpairable line in file file_number.
(The argument to <b>-a</b> must not be preceded by a space; see the <a href="http://search.cpan.org/perldoc?COMPATIBILITY" class="podlinkpod"
>COMPATIBILITY</a> section.)</dd><p class="pad"></p>

<dt><a name="-e_string"
><b>-e</b> <i>string</i></a></dt><p class="pad"></p>

<dd>Replace empty output fields with <i>string</i>.</dd><p class="pad"></p>

<dt><a name="-o_field-list"
><b>-o</b> <i><i>field-list</i></i></a></dt><p class="pad"></p>

<dd>Construct each output line according to the format in <i>field-list</i>.
Each element in <i>field-list</i> is either the single character `0&#39; or has the form M.N where the file number,
M,
is `1&#39; or `2&#39; and N is a positive field number.</dd><p class="pad"></p>

<dd>A field specification of `0&#39; denotes the join field.
In most cases,
the functionality of the `0&#39; field spec may be reproduced using the explicit M.N that corresponds to the join field.
However,
when printing unpairable lines (using either of the <b>-a</b> or <b>-v</b> options),
there is no way to specify the join field using M.N in <i>field-list</i> if there are unpairable lines in both files.
To give <b>join</b> that functionality,
POSIX invented the `0&#39; field specification notation.</dd><p class="pad"></p>

<dd>The elements in <i>field-list</i> are separated by commas or blanks.
Multiple <i>field-list</i> arguments can be given after a single <b>-o</b> option; the values of all lists given with <b>-o</b> are concatenated together.
All output lines - including those printed because of any <b>-a</b> or <b>-v</b> option - are subject to the specified <i>field-list</i>.</dd><p class="pad"></p>

<dt><a name="-t_char"
><b>-t</b> <i>char</i></a></dt><p class="pad"></p>

<dd>Use character <i>char</i> as a field separator for both input and output.
Every occurrence of <i>char</i> in a line is significant.</dd><p class="pad"></p>

<dt><a name="-v_file_number"
><b>-v</b> <i>file_number</i></a></dt><p class="pad"></p>

<dd>Do not display the default output,
but display a line for each unpairable line in file <i>file_number</i>.
The options <b>-v 1</b> and <b>-v 2</b> may be specified at the same time.</dd><p class="pad"></p>

<dt><a name="-1_field"
><b>-1</b> <i>field</i></a></dt><p class="pad"></p>

<dd>Join on the <i>field</i>&#39;th field of file 1.</dd><p class="pad"></p>

<dt><a name="-2_field"
><b>-2</b> <i>field</i></a></dt><p class="pad"></p>

<dd>Join on the <i>field</i>&#39;th field of file 2.</dd><p class="pad"></p>
</dl>

<p>When the default field delimiter characters are used,
the files to be joined should be ordered in the collating sequence of <a>sort(1)</a>,
using the <b>-b</b> option,
on the fields on which they are to be joined,
otherwise <b>join</b> may not report all field matches.
When the field delimiter characters are specified by the <b>-t</b> option,
the collating sequence should be the same as sort without the <b>-b</b> option.</p>

<p>If one of the arguments <i>file1</i> or <i>file2</i> is ``-&#39;&#39;,
the standard input is used.</p>

<p>The <b>join</b> utility exits 0 on success or &#62;0 if an error occurred.</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="COMPATIBILITY"
>COMPATIBILITY</a></h1>

<p>For compatibility with historic versions of join,
the following options are available:</p>

<dl>
<dt><a name="-j1_field"
><b>-j1</b> <i>field</i></a></dt><p class="pad"></p>

<dd>Join on the <i>field</i>&#39;th field of file 1.</dd><p class="pad"></p>

<dt><a name="-j2_field"
><b>-j2</b> <i>field</i></a></dt><p class="pad"></p>

<dd>Join on the <i>field</i>&#39;th field of file 2.</dd><p class="pad"></p>

<dt><a name="-j_field"
><b>-j</b> <i>field</i></a></dt><p class="pad"></p>

<dd>Join on the <i>field</i>&#39;th field of both file 1 and file 2.</dd><p class="pad"></p>

<dt><a name="-o_list_..."
><b>-o</b> <i>list</i> <i>...</i></a></dt><p class="pad"></p>

<dd>Historical implementations of <b>join</b> permitted multiple arguments to the <b>-o</b> option.
These arguments were of the form ``<i>file_number</i>.<i>field_number</i>&#39;&#39; as described for the current -o option.
This has obvious difficulties in the presence of files named ``1.2&#39;&#39;.</dd><p class="pad"></p>
</dl>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="SEE_ALSO"
>SEE ALSO</a></h1>

<p><a>awk(1)</a>,
<a>comm(1)</a>,
<a>paste(1)</a>,
<a>sort(1)</a>,
<a>uniq(1)</a></p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="BUGS"
>BUGS</a></h1>

<p><i>join</i> has no known bugs.
It does not support the following historical switches: <b>-a</b> with no args.
Patches are welcome.</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="AUTHOR"
>AUTHOR</a></h1>

<p>The Perl implementation of <i>join</i> was written by Jonathan Feinberg,
<i>jdf@pobox.com</i>.</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="COPYRIGHT_and_LICENSE"
>COPYRIGHT and LICENSE</a></h1>

<p>This program is copyright (c) Jonathan Feinberg 1999.</p>

<p>This program is free and open software.
You may use,
modify,
distribute,
and sell this program (and any modified variants) in any way you wish,
provided you do not restrict others from doing the same.</p>

<!-- end doc -->

</body></html>