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

 

 

魂内検索

DOCUMENTS

COMMAND

FORUM

UEC DOCS

VIDEO

 

Alphabetical list

(Video materials in preparation)

up3(USP)

Name

up3 : Merges two files on the same key field

Synopsis

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

Options : -e

          -s<c>

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

Edition : 3

Description

The key field specified as key=<key> of each record of the

transaction file passed as argument <tran> (or standard input)

is compared to the same field of the master file <master>,

and where the keys match the records from the transaction file

are inserted below the matching record in the master file.

The key fields in <master> and <tran> must be sorted.

<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)

Example 1

$ cat master       # Data from days 1-3

Store_A Day_1 103 62

Store_A Day_2 157 94

Store_A Day_3 62 30

Store_B Day_1 210 113

Store_B Day_2 237 121

Store_B Day_3 150 82

Store_C Day_1 81 52

Store_C Day_2 76 49

Store_C Day_3 38 21

$ cat tran         # Data from days 4-5

Store_A Day_4 131 84

Store_A Day_5 189 111

Store_B Day_4 198 105

Store_B Day_5 259 189

Store_C Day_4 81 48

Store_C Day_5 98 61

$ up3 key=1 master tran > data

$ cat data          <- Days 1-5 are merged

Store_A Day_1 103 62

Store_A Day_2 157 94

Store_A Day_3 62 30

Store_A Day_4 131 84    <- Beneath the "Store_A" records in "master"

Store_A Day_5 189 111   <- The "Store_A" records in "tran" are inserted

Store_B Day_1 210 113

Store_B Day_2 237 121

Store_B Day_3 150 82

Store_B Day_4 198 105

Store_B Day_5 259 189

Store_C Day_1 81 52

Store_C Day_2 76 49

Store_C Day_3 38 21

Store_C Day_4 81 48

Store_C Day_5 98 61