(Video materials in preparation)
join2x : Joins to files where more than one record has
matching key values.
Usage : join2x key=<key> <master> <tran>
Options : +<string>
-f<n>
-e
-s<c>
Version : Tue Jan 9 09:02:34 JST 2024
Edition : 1
Only those records in the text file <tran> where the <key> fields of
<tran> match corresponding fields of <master> are selected, then
joined with the fields in <master> and output. The join occurs by
adding the fields from <master> immediately after the <key> fields
in <tran>. For records that do not match, padding data "_" is joined
for the amount of fields in master. It is also possible to specify
different padding data by +<string> option.
<key> designates the field position as fllows:
single field 2 the 2nd field
NF the last field
NF-1 the field just before the last field
contiguous fields 2/4 from the 2nd field to the 4th field
4/2 from the 4th field to the 2nd field
NF-3/NF from NF-3 field to the NF field
combination 2@NF the 2nd field and the NF field
There is no limit on the length of the key field or on the number
of key fields. The key field can also contain multi-byte characters
such as Japanese.
If you specify "r" as comparison method after the field position,
the fields are compared in reverse order. If you specify "n" as
comparison method after the field position, that field's values will
be compared as numbers. If you specify "nr" as comparison method
after the field, the values will be compared in reverse order as
numbers. If you specify comparison method before or after the "/",
you must use the same comparison method for both fields.
2n/5n OK
2n/5nr Error
2n/5r Error
When you specify "e" as comparison method or specify -e ootion and no
method, characters in the field are replaced as follows and compared
as string:
_ ==> 0x20 (space)
\0 ==> 0x00 (null)
\t ==> 0x09 (tab stop)
\n ==> 0x0a (new line)
\r ==> 0x0d (carrige return)
\_ ==> 0x5f (underscore)
\\ ==> 0x5c (back slash)
If the file name is omitted or if it is specified as "-" then the
command will read from standard input.
The <key> fields in <master> and <tran> MUST be sorted. However,
the difference between this command and join1 is that there may be
more than one record in <master> that share the same key value (join2
requires the key fields in <master> to be unique).
If <master> is an empty file (0 bytes) an error is generated. If
-f<n> option is specified, this error is not generated and <n> is
used as number of non-key fields of <master>.
$ cat master (Master)
1 New_York1
1 New_York2
2 Boston1
2 Boston2
$ cat tran (Transaction)
1 Uptown
1 Harlem
2 Back_Bay
2 West_End
2 North_End
3 Georgetown
3 Dupont
3 Foggy_Bottom
4 South_Beach
4 Little_Havana
$ join2x key=1 master tran
1 New_York1 Uptown
1 New_York2 Uptown
1 New_York1 Harlem
1 New_York2 Harlem
2 Boston1 Back_Bay
2 Boston2 Back_Bay
2 Boston1 West_End
2 Boston2 West_End
2 Boston1 North_End
2 Boston2 North_End
3 _ Georgetown
3 _ Dupont
3 _ Foggy_Bottom
4 _ South_Beach
4 _ Little_Havana