1join(1)                          User Commands                         join(1)
2
3
4

NAME

6       join - relational database operator
7

SYNOPSIS

9       join [-a filenumber | -v filenumber] [-1 fieldnumber]
10            [-2 fieldnumber] [-o list] [-e string] [-t char] file1 file2
11
12
13       join [-a filenumber] [-j fieldnumber] [-j1 fieldnumber]
14            [-j2 fieldnumber] [-o list] [-e string] [-t char] file1 file2
15
16

DESCRIPTION

18       The join command forms, on the standard output, a join of the two rela‐
19       tions specified by the lines of file1 and file2.
20
21
22       There is one line in the output for each pair of  lines  in  file1  and
23       file2  that  have  identical join fields. The output line normally con‐
24       sists of the common field, then the rest of the line from  file1,  then
25       the  rest  of  the line from file2. This format can be changed by using
26       the -o option (see below). The -a option can be used to  add  unmatched
27       lines to the output. The -v option can be used to output only unmatched
28       lines.
29
30
31       The default input field separators are blank, tab, or new-line. In this
32       case,  multiple  separators  count  as one field separator, and leading
33       separators are ignored. The default output field separator is a blank.
34
35
36       If the input files are not in the appropriate collating  sequence,  the
37       results are unspecified.
38

OPTIONS

40       Some  of  the  options below use the argument filenumber. This argument
41       should be a 1 or a 2 referring to either file1 or file2, respectively.
42
43       -a filenumber       In addition to the normal output,  produce  a  line
44                           for  each unpairable line in file filenumber, where
45                           filenumber is 1 or 2. If both -a 1  and  -a  2  are
46                           specified, all unpairable lines will be output.
47
48
49       -e string           Replace empty output fields in the list selected by
50                           option -o with the string string.
51
52
53       -j fieldnumber      Equivalent to -1fieldnumber -2fieldnumber.
54
55
56       -j1 fieldnumber     Equivalent to -1fieldnumber.
57
58
59       -j2 fieldnumber     Equivalent to -2fieldnumber.  Fields  are  numbered
60                           starting with 1.
61
62
63       -o list             Each  output  line includes the fields specified in
64                           list. Fields selected by list that do not appear in
65                           the  input  will be treated as empty output fields.
66                           (See the -e option.) Each element of which has  the
67                           either the form filenumber.fieldnumber, or 0, which
68                           represents the join field. The common field is  not
69                           printed unless specifically requested.
70
71
72       -t char             Use character char as a separator. Every appearance
73                           of char in a line  is  significant.  The  character
74                           char  is used as the field separator for both input
75                           and output. With this option specified, the collat‐
76                           ing  term should be the same as sort without the -b
77                           option.
78
79
80       -v filenumber       Instead of the default output, produce a line  only
81                           for  each  unpairable  line  in  filenumber,  where
82                           filenumber is 1 or 2. If both -v 1  and  -v  2  are
83                           specified, all unpairable lines will be output.
84
85
86       -1 fieldnumber      Join  on  the fieldnumberth field of file 1. Fields
87                           are decimal integers starting with 1.
88
89
90       -2fieldnumber       Join on the fieldnumberth field of file  2.  Fields
91                           are decimal integers starting with 1.
92
93

OPERANDS

95       The following operands are supported:
96
97       file1
98
99
100       file2     A path name of a file to be joined. If either of the file1 or
101                 file2 operands is , the standard input is used in its place.
102
103
104
105       file1 and file2 must be sorted  in  increasing  collating  sequence  as
106       determined  by LC_COLLATE on the fields on which they are to be joined,
107       normally the first in each line (see sort(1)).
108

USAGE

110       See largefile(5) for the description  of  the  behavior  of  join  when
111       encountering files greater than or equal to 2 Gbyte (2^31 bytes).
112

EXAMPLES

114       Example 1 Joining the password file and group file
115
116
117       The  following  command  line will join the password file and the group
118       file, matching on the numeric group ID, and outputting the login  name,
119       the  group  name  and the login directory. It is assumed that the files
120       have been sorted in ASCII collating sequence on the group ID fields.
121
122
123         example% join -j1 4-j2 3 -o 1.1 2.1 1.6 -t:/etc/passwd /etc/group
124
125
126
127       Example 2 Using the -o option
128
129
130       The -o 0 field essentially selects the union of the  join  fields.  For
131       example, given file phone:
132
133
134         !Name           Phone Number
135         Don             +1 123-456-7890
136         Hal             +1 234-567-8901
137         Yasushi         +2 345-678-9012
138
139
140
141
142       and file fax:
143
144
145         !Name           Fax Number
146
147         Don             +1 123-456-7899
148
149         Keith           +1 456-789-0122
150
151         Yasushi         +2 345-678-9011
152
153
154
155
156       where  the  large expanses of white space are meant to each represent a
157       single tab character), the command:
158
159
160         example% join -t"tab" -a 1 -a 2 -e '(unknown)' -o 0,1.2,2.2 phone fax
161
162
163
164
165       would produce
166
167
168         !Name           Phone Number           Fax Number
169         Don             +1 123-456-7890         +1 123-456-7899
170         Hal             +1 234-567-8901         (unknown
171         Keith           (unknown)               +1 456-789-012
172         Yasushi         +2 345-678-9012         +2 345-678-9011
173
174
175

ENVIRONMENT VARIABLES

177       See environ(5) for descriptions of the following environment  variables
178       that affect the execution of join: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES,
179       LC_COLLATE, and NLSPATH.
180

EXIT STATUS

182       The following exit values are returned:
183
184       0      All input files were output successfully.
185
186
187       >0     An error occurred.
188
189

ATTRIBUTES

191       See attributes(5) for descriptions of the following attributes:
192
193
194
195
196       ┌─────────────────────────────┬─────────────────────────────┐
197       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
198       ├─────────────────────────────┼─────────────────────────────┤
199       │Availability                 │SUNWcsu                      │
200       ├─────────────────────────────┼─────────────────────────────┤
201       │CSI                          │Enabled                      │
202       ├─────────────────────────────┼─────────────────────────────┤
203       │Interface Stability          │Standard                     │
204       └─────────────────────────────┴─────────────────────────────┘
205

SEE ALSO

207       awk(1), comm(1), sort(1), uniq(1),  attributes(5),  environ(5),  large‐
208       file(5), standards(5)
209

NOTES

211       With  default  field separation, the collating sequence is that of sort
212       -b; with -t, the sequence is that of a plain sort.
213
214
215       The conventions of the join, sort, comm, uniq,  and  awk  commands  are
216       wildly incongruous.
217
218
219
220SunOS 5.11                        8 Feb 2000                           join(1)
Impressum