uspTukubaiコマンドに関する様々な資料がここにあります。

 

 

魂内検索

DOCUMENTS

COMMAND

FORUM

UEC DOCS

VIDEO

 

Alphabetical list

(Video materials in preparation)

tagupl(USP)

Name

tagupl : Merges two files on the same key field and then extracts

           the final line of a group of lines that share the same key

           value.

Synopsis

Usage   : tagupl key=<key> <master> <tran>

Options : -e

          -s<c>

Version : Tue Jan  9 09:02:34 JST 2024

Edition : 2

Description

Selects all rows of tag-formatted file <tran> (or standard input)

where the value of the key field specified as key=<tag> matches

the value of the field with the same same key in tag-formatted

<master>, then merges those rows below the row in <master> and

finally extracts the last record in the group of rows that share

the same key value.  Both <master> and <tran> must be sorted.

If <master> is specified as "-" then the command reads from standard

input.  If <tran> is not specified or specified as "-" then the

command reads from standard input.

If <master> or <tran> are 0 byte files, an error occurs.  Even if

<master> or <tran> are null files (only contain tags) the command

exits 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

Limitations

1. <master> and <trans> must be sorted on the key field with the

   exception of the first row (tag header).

2. <master> and <tran> must have the same tags.

Example 1

$ cat master

CODE NAME AGE SEX

0003 SMITH  026 WOM

0005 JONES  050 MAN

0007 NEWTON 042 WOM

$ cat tran

CODE NAME AGE SEX

0003 SMITH  030 WOM

0009 WILSON 035 MAN

$ tagupl key=CODE master tran

CODE NAME AGE SEX

0003 SMITH  030 WOM

0005 JONES  050 MAN

0007 NEWTON 042 WOM

0009 WILSON 035 MAN

Example 2 Read from standard input

$ cat tran   | tagupl key=CODE master

$ cat tran   | tagupl key=CODE master -

$ cat master | tagupl key=CODE - tag-tran