.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.30) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "JOIN 1" .TH JOIN 1 "2001-06-06" "perl v5.20.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" join \- relational database operator .SH "SYNOPSIS" .IX Header "SYNOPSIS" join [\fB\-a\fR \fIfile_number\fR | \fB\-v\fR \fIfile_number\fR] [\fB\-e\fR \fIstring\fR] [\fB\-o\fR \fIlist\fR] [\fB\-t\fR \fIchar\fR] [\fB\-1\fR \fIfield\fR] [\fB\-2\fR \fIfield\fR] \fIfile1\fR \fIfile2\fR .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBjoin\fR utility performs an ``equality join'' on the specified files and writes the result to the standard output. The ``join field'' 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 \fIfile1\fR and \fIfile2\fR which have identical join fields. Each output line consists of the join field, the remaining fields from \fIfile1\fR and then the remaining fields from \&\fIfile2\fR. .PP 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 \fIfile1\fR, then the remaining fields from \fIfile2\fR. .PP 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: .IP "\fB\-a\fR \fIfile_number\fR" 4 .IX Item "-a file_number" In addition to the default output, produce a line for each unpairable line in file file_number. (The argument to \fB\-a\fR must not be preceded by a space; see the \s-1COMPATIBILITY\s0 section.) .IP "\fB\-e\fR \fIstring\fR" 4 .IX Item "-e string" Replace empty output fields with \fIstring\fR. .IP "\fB\-o\fR \fI\fIfield-list\fI\fR" 4 .IX Item "-o field-list" Construct each output line according to the format in \fIfield-list\fR. Each element in \fIfield-list\fR is either the single character `0' or has the form M.N where the file number, M, is `1' or `2' and N is a positive field number. .Sp A field specification of `0' denotes the join field. In most cases, the functionality of the `0' 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 \fB\-a\fR or \fB\-v\fR options), there is no way to specify the join field using M.N in \&\fIfield-list\fR if there are unpairable lines in both files. To give \&\fBjoin\fR that functionality, \s-1POSIX\s0 invented the `0' field specification notation. .Sp The elements in \fIfield-list\fR are separated by commas or blanks. Multiple \fIfield-list\fR arguments can be given after a single \fB\-o\fR option; the values of all lists given with \fB\-o\fR are concatenated together. All output lines \- including those printed because of any \&\fB\-a\fR or \fB\-v\fR option \- are subject to the specified \fIfield-list\fR. .IP "\fB\-t\fR \fIchar\fR" 4 .IX Item "-t char" Use character \fIchar\fR as a field separator for both input and output. Every occurrence of \fIchar\fR in a line is significant. .IP "\fB\-v\fR \fIfile_number\fR" 4 .IX Item "-v file_number" Do not display the default output, but display a line for each unpairable line in file \fIfile_number\fR. The options \fB\-v 1\fR and \fB\-v 2\fR may be specified at the same time. .IP "\fB\-1\fR \fIfield\fR" 4 .IX Item "-1 field" Join on the \fIfield\fR'th field of file 1. .IP "\fB\-2\fR \fIfield\fR" 4 .IX Item "-2 field" Join on the \fIfield\fR'th field of file 2. .PP When the default field delimiter characters are used, the files to be joined should be ordered in the collating sequence of \fIsort\fR\|(1), using the \fB\-b\fR option, on the fields on which they are to be joined, otherwise \fBjoin\fR may not report all field matches. When the field delimiter characters are specified by the \fB\-t\fR option, the collating sequence should be the same as sort without the \fB\-b\fR option. .PP If one of the arguments \fIfile1\fR or \fIfile2\fR is ``\-'', the standard input is used. .PP The \fBjoin\fR utility exits 0 on success or >0 if an error occurred. .SH "COMPATIBILITY" .IX Header "COMPATIBILITY" For compatibility with historic versions of join, the following options are available: .IP "\fB\-j1\fR \fIfield\fR" 4 .IX Item "-j1 field" Join on the \fIfield\fR'th field of file 1. .IP "\fB\-j2\fR \fIfield\fR" 4 .IX Item "-j2 field" Join on the \fIfield\fR'th field of file 2. .IP "\fB\-j\fR \fIfield\fR" 4 .IX Item "-j field" Join on the \fIfield\fR'th field of both file 1 and file 2. .IP "\fB\-o\fR \fIlist\fR \fI...\fR" 4 .IX Item "-o list ..." Historical implementations of \fBjoin\fR permitted multiple arguments to the \fB\-o\fR option. These arguments were of the form ``\fIfile_number\fR.\fIfield_number\fR'' as described for the current \&\-o option. This has obvious difficulties in the presence of files named ``1.2''. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIawk\fR\|(1), \fIcomm\fR\|(1), \fIpaste\fR\|(1), \fIsort\fR\|(1), \fIuniq\fR\|(1) .SH "BUGS" .IX Header "BUGS" \&\fIjoin\fR has no known bugs. It does not support the following historical switches: \fB\-a\fR with no args. Patches are welcome. .SH "AUTHOR" .IX Header "AUTHOR" The Perl implementation of \fIjoin\fR was written by Jonathan Feinberg, \&\fIjdf@pobox.com\fR. .SH "COPYRIGHT and LICENSE" .IX Header "COPYRIGHT and LICENSE" This program is copyright (c) Jonathan Feinberg 1999. .PP 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.