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

 

 

魂内検索

DOCUMENTS

COMMAND

FORUM

UEC DOCS

VIDEO

 

Alphabetical list

(Video materials in preparation)

taggetlast(USP)

Name

taggetlast : Outputs the last record with a matching key.

Synopsis

Usage   : taggetlast <tag1> <tag2> <file>

          taggetlast key=<key> <file>

Options : +ng[<fd>]

          -<n>

          -e

          -s<c>

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

Edition : 2

Description

If there are multiple records within the file passed as an argument

or standard input where the specified key fields contains the same

value, only the last record is output.  If -<n> is specified, the

last <n> records are output.

There are tow methods to specify key fields: <tag1> <tag2> (from

<tag1> field to <tag2> field) and key=<key>.  <key> designates the

<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

Example 1

(Original Data: ProdCode ProdName SaleDate QtySold)

$ cat data

CODE ProdName DateSold QtySold

0000007 Celery 20060201 117

0000007 Celery 20060202 136

0000007 Celery 20060203 221

0000017 Carrot 20060201 31

0000017 Carrot 20060202 127

0000017 Carrot 20060203 514

0000021 Orange 20060201 90

0000021 Orange 20060202 324

0000021 Orange 20060203 573

0000025 Melon 20060201 129

0000025 Melon 20060202 493

0000025 Melon 20060203 391

0000030 Potato 20060201 575

0000030 Potato 20060202 541

0000030 Potato 20060203 184

$ taggetlast CODE ProdName data >data2

$ cat data2                 <- Last record with same product is output.

CODE ProdName DateSold QtySold

0000007 Celery 20060203 221

0000017 Carrot 20060203 514

0000021 Orange 20060203 573

0000025 Melon 20060203 391

0000030 Potato 20060203 184

Example 2

The "+ng" option outputs to standard error all records that

match the key field except for the last record.

$ taggetlast +ng CODE ProdName data >/dev/null 2>data2

$ cat data2

CODE ProdName DateSold QtySold

0000007 Celery 20060201 117

0000007 Celery 20060202 136

0000017 Carrot 20060201 31

0000017 Carrot 20060202 127

0000021 Orange 20060201 90

0000021 Orange 20060202 324

0000025 Melon 20060201 129

0000025 Melon 20060202 493

0000030 Potato 20060201 575

0000030 Potato 20060202 541

Example 3

If <fd> is specified with the +ng option, instead of outputting

to standard error, the command outputs to <fd>.

$ taggetlast +ng4 CODE ProdName data >/dev/null 4>data2

$ cat data2

CODE ProdName DateSold QtySold

0000007 Celery 20060201 117

0000007 Celery 20060202 136

0000017 Carrot 20060201 31

0000017 Carrot 20060202 127

0000021 Orange 20060201 90

0000021 Orange 20060202 324

0000025 Melon 20060201 129

0000025 Melon 20060202 493

0000030 Potato 20060201 575

0000030 Potato 20060202 541