(Video materials in preparation)
tagcjoin1x : Joins together tag data that exists in the tag master.
Records that do not exist are discarded.
Usage : tagcjoin1x key=<tag> <master> <tran>
Options : +ng[<fd>]
-e
-s<c>
Version : Tue Jan 9 09:02:34 JST 2024
Edition : 1
Matches the key field as specified by key=<key> in tag-formatted
file <master> with tag-formateed file <tran>, joins the matching
records in tag format and outputs them to standard output.
The difference between this command and tagcjoin1 is that more than
one record in <master> can have a key field with the same value. If
more than one record with the same key field value exists, then the
records are joined in all possible combinations.
Non-matching records are discarded, however if you specify the +ng
option then these records are output in tag format to standard error.
If you specify "-" as <master> then it will be read from standard
input. If you omit <tran> or specify "-" then it will be read from
standard input.
If either <master> or <tran> are empty files, an error occurs. If
either <master> or <tran> are null files (only contain the tag
record) the command processes normally.
<key> designates the field position as fllows:
single field TAGa TAGa field
contiguous fields TAGa/TAGb from TAGa field to TAGb field
combination TAGa@TAGb TAGa field and TAGb 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.
TAGa:n/TAGb:n OK
TAGa:n/TAGb:nr Error
TAGa:n/TAGb:r 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)
The tag name specfying the field can be eclosed by braces {}. In
this case, tag names can include special charcter like "/" or "@".
Moreover, tag names can include pairs of braces. When comparison
method is attached to brace enclosed tag name, ":" should be ommited.
{TAGa}n/{TAGb}n
1. <master> must be sorted on the key field, excluding the first
record (tag record).
$ cat master
CODE NAME AGE SEX
0003 SMITH 026 WOM
0005 JONES 050 MAN
0005 JONES 048 WOM
0007 BROWN 042 WOM
$ cat tran
SEQ CODE A1 A2 A3
001 0005 82 79 16
001 0004 58 71 20
001 0003 30 50 71
$ tagcjoin1x key=CODE master tran > ok-data
$ cat ok-data
SEQ CODE NAME AGE SEX A1 A2 A3
001 0005 JONES 050 MAN 82 79 16
001 0005 JONES 048 WOM 82 79 16
001 0003 SMITH 026 WOM 30 50 71
$ tagcjoin1x +ng3 key=CODE master tran > ok-data 3> ng-data
$ cat ok-data
SEQ CODE NAME AGE SEX A1 A2 A3
001 0005 JONES 050 MAN 82 79 16
001 0005 JONES 048 WOM 82 79 16
001 0003 SMITH 026 WOM 30 50 71
$ cat ng-data
SEQ CODE A1 A2 A3
001 0004 58 71 20
If <fd> is omitted, non-matching records are output on stderr
$ tagcjoin1x +ng key=CODE master tran > ok-data 2> ng-data
$ cat master | tagcjoin1x key=CODE - tran
$ cat tran | tagcjoin1x key=CODE master -
$ cat tran | tagcjoin1x key=CODE master # "-" can be omitted