147 lines · 2.5 KB · Text
RawDownload
.TH JOIN 1.CT 1 files.SH NAMEjoin \- relational database operator.SH SYNOPSIS.B join[.I options].I file1 file2.SH DESCRIPTION.I Joinforms, on the standard output,a joinof the two relations specified by the lines of.I file1and.IR file2 .If one of the file names is.LR - ,the standard input is used..PP.I File1and.I file2must be sorted in increasing.SM ASCII collatingsequence on the fieldson which they are to be joined,normally the first in each line..PPThere is one line in the outputfor each pair of lines in.I file1and.I file2that have identical join fields.The output line normally consists of the common field,then the rest of the line from.IR file1 ,then the rest of the line from.IR file2 ..PPInput fields are normally separated spaces or tabs;output fields by space.In this case, multiple separators count as one, andleading separators are discarded..PPThe following options are recognized, with POSIX syntax..TP.BI -a " nIn addition to the normal output,produce a line for each unpairable line in file.IR n ,where.I nis 1 or 2..TP.BI -v " nLike.BR -a ,omitting output for paired lines..TP.BI -e " sReplace empty output fields by string.IR s ..TP.BI -1 " m.br.ns.TP.BI -2 " mJoin on the.IR m thfield of.I file1or.IR file2 ..TP.BI -j "n m"Archaic equivalent for.BI - n " m"\f1..TP.BI -o fieldsEach output line comprises the designated fields.The comma-separated field designators are either.BR 0 ,meaning the join field, or have the form.IR n . m ,where.I nis a file number and.I mis a field number.Archaic usage allows separate arguments for field designators..PP.TP.BI -t cUse character.I cas the only separator (tab character) on input and output.Every appearance of.I cin a line is significant..SH EXAMPLES.TP.Lsort -t: +1 /adm/users | join -t: -1 2 -a 1 -e "" - bdaysAdd birthdays to the.B /adm/usersfile, leaving unknownbirthdays empty.The layout of .B /adm/usersis given in.IR users (6);.B bdayscontains sorted lines like.LR "ken:Feb\ 4,\ 1953" ..TP.Ltr : ' ' </adm/users | sort -k 3 3 >temp.br.ns.TP.Ljoin -1 3 -2 3 -o 1.1,2.1 temp temp | awk '$1 < $2'Print all pairs of users with identical userids..SH SOURCE.B /sys/src/cmd/join.c.SH "SEE ALSO".IR sort (1), .IR comm (1), .IR awk (1).SH BUGSWith default field separation,the collating sequence is that of.BI "sort -b".BI -k y , y\f1;with.BR -t ,the sequence is that of.BI "sort -t" x.BI -k y , y\f1..PPOne of the files must be randomly accessible.