📄 join.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>join</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="join"></a> <a name="tag_04_71"></a><!-- join --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright © 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_04_71_01"></a>NAME</h4><blockquote>join - relational database operator</blockquote><h4><a name="tag_04_71_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>join</tt> <b>[</b><tt>-a</tt> <i>file_number</i> <tt>| -v</tt> <i>file_number</i><b>][</b><tt>-e</tt><i>string</i><b>][</b><tt>-o</tt> <i>list</i><b>][</b><tt>-t</tt> <i>char</i><b>]<br></b> <tt> </tt> <b>[</b><tt>-1</tt> <i>field</i><b>][</b><tt>-2</tt> <i>field</i><b>]</b><i>file1 file2</i></code></p></blockquote><h4><a name="tag_04_71_03"></a>DESCRIPTION</h4><blockquote><p>The <i>join</i> utility shall perform an equality join on the files <i>file1</i> and <i>file2</i>. The joined files shall bewritten to the standard output.</p><p>The join field is a field in each file on which the files are compared. The <i>join</i> utility shall write one line in theoutput for each pair of lines in <i>file1</i> and <i>file2</i> that have identical join fields. The output line by default shallconsist of the join field, then the remaining fields from <i>file1</i>, then the remaining fields from <i>file2</i>. This formatcan be changed by using the <b>-o</b> option (see below). The <b>-a</b> option can be used to add unmatched lines to the output.The <b>-v</b> option can be used to output only unmatched lines.</p><p>The files <i>file1</i> and <i>file2</i> shall be ordered in the collating sequence of <a href="../utilities/sort.html"><i>sort</i></a> <b>-b</b> on the fields on which they shall be joined, by default the first in each line.All selected output shall be written in the same collating sequence.</p><p>The default input field separators shall be <blank>s. In this case, multiple separators shall count as one fieldseparator, and leading separators shall be ignored. The default output field separator shall be a <space>.</p><p>The field separator and collating sequence can be changed by using the <b>-t</b> option (see below).</p><p>If the same key appears more than once in either file, all combinations of the set of remaining fields in <i>file1</i> and theset of remaining fields in <i>file2</i> are output in the order of the lines encountered.</p><p>If the input files are not in the appropriate collating sequence, the results are unspecified.</p></blockquote><h4><a name="tag_04_71_04"></a>OPTIONS</h4><blockquote><p>The <i>join</i> utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap12.html#tag_12_02">Section 12.2, Utility Syntax Guidelines</a>.</p><p>The following options shall be supported:</p><dl compact><dt><b>-a </b> <i>file_number</i></dt><dd><br>Produce a line for each unpairable line in file <i>file_number</i>, where <i>file_number</i> is 1 or 2, in addition to the defaultoutput. If both <b>-a</b>1 and <b>-a</b>2 are specified, all unpairable lines shall be output.</dd><dt><b>-e </b> <i>string</i></dt><dd>Replace empty output fields in the list selected by <b>-o</b> with the string <i>string</i>.</dd><dt><b>-o </b> <i>list</i></dt><dd>Construct the output line to comprise the fields specified in <i>list</i>, each element of which shall have one of thefollowing two forms: <ol><li><p><i>file_number.field</i>, where <i>file_number</i> is a file number and <i>field</i> is a decimal integer field number</p></li><li><p>0 (zero), representing the join field</p></li></ol><p>The elements of <i>list</i> shall be either comma-separated or <blank>-separated, as specified in Guideline 8 of the BaseDefinitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap12.html#tag_12_02">Section 12.2, Utility SyntaxGuidelines</a>. The fields specified by <i>list</i> shall be written for all selected output lines. Fields selected by <i>list</i>that do not appear in the input shall be treated as empty output fields. (See the <b>-e</b> option.) Only specifically requestedfields shall be written. The application shall ensure that <i>list</i> is a single command line argument.</p></dd><dt><b>-t </b> <i>char</i></dt><dd>Use character <i>char</i> as a separator, for both input and output. Every appearance of <i>char</i> in a line shall besignificant. When this option is specified, the collating sequence shall be the same as <a href="../utilities/sort.html"><i>sort</i></a> without the <b>-b</b> option.</dd><dt><b>-v </b> <i>file_number</i></dt><dd><br>Instead of the default output, produce a line only for each unpairable line in <i>file_number</i>, where <i>file_number</i> is 1 or2. If both <b>-v</b>1 and <b>-v</b>2 are specified, all unpairable lines shall be output.</dd><dt><b>-1 </b> <i>field</i></dt><dd>Join on the <i>field</i>th field of file 1. Fields are decimal integers starting with 1.</dd><dt><b>-2 </b> <i>field</i></dt><dd>Join on the <i>field</i>th field of file 2. Fields are decimal integers starting with 1.</dd></dl></blockquote><h4><a name="tag_04_71_05"></a>OPERANDS</h4><blockquote><p>The following operands shall be supported:</p><dl compact><dt><i>file1</i>, <i>file2</i></dt><dd>A pathname of a file to be joined. If either of the <i>file1</i> or <i>file2</i> operands is <tt>'-'</tt> , the standard inputshall be used in its place.</dd></dl></blockquote><h4><a name="tag_04_71_06"></a>STDIN</h4><blockquote><p>The standard input shall be used only if the <i>file1</i> or <i>file2</i> operand is <tt>'-'</tt> . See the INPUT FILESsection.</p></blockquote><h4><a name="tag_04_71_07"></a>INPUT FILES</h4><blockquote><p>The input files shall be text files.</p></blockquote><h4><a name="tag_04_71_08"></a>ENVIRONMENT VARIABLES</h4><blockquote><p>The following environment variables shall affect the execution of <i>join</i>:</p><dl compact><dt><i>LANG</i></dt><dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume ofIEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> forthe precedence of internationalization variables used to determine the values of locale categories.)</dd><dt><i>LC_ALL</i></dt><dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd><dt><i>LC_COLLATE</i></dt><dd><br>Determine the locale of the collating sequence <i>join</i> expects to have been used when the input files were sorted.</dd><dt><i>LC_CTYPE</i></dt><dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte asopposed to multi-byte characters in arguments and input files).</dd><dt><i>LC_MESSAGES</i></dt><dd>Determine the locale that should be used to affect the format and contents of diagnostic messages written to standarderror.</dd><dt><i>NLSPATH</i></dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Determine the location of message catalogs for the processing of <i>LC_MESSAGES .</i> <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl></blockquote><h4><a name="tag_04_71_09"></a>ASYNCHRONOUS EVENTS</h4><blockquote><p>Default.</p></blockquote><h4><a name="tag_04_71_10"></a>STDOUT</h4><blockquote><p>The <i>join</i> utility output shall be a concatenation of selected character fields. When the <b>-o</b> option is notspecified, the output shall be:</p><pre><tt>"%s%s%s\n", <</tt><i>join field</i><tt>>, <</tt><i>other file1 fields</i><tt>>, <</tt><i>other file2 fields</i><tt>></tt></pre><p>If the join field is not the first field in a file, the <<i>other file fields</i>> for that file shall be:</p><pre><tt><</tt><i>fields preceding join field</i><tt>>, <</tt><i>fields following join field</i><tt>></tt></pre><p>When the <b>-o</b> option is specified, the output format shall be:</p><pre><tt>"%s\n", <</tt><i>concatenation of fields</i><tt>>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -