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

 

 

魂内検索

DOCUMENTS

COMMAND

FORUM

UEC DOCS

VIDEO

 

Alphabetical list

(Video materials in preparation)

tagrank(USP)

Name

tagrank : Add a rank

Synopsis

Usage   : tagrank [ref=<ref>] [key=<key>] <file>

Options : -e

          -s<c>

          --tagname=<tag>

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

Edition : 1

Description

Add line numbers to "file". If a reference key field is specified

with "ref=<ref>", then the line numbers are restarted at 1 whenever

the value in the reference key field changes.

If a value field is specified with "key=<key>" then the same line

number is assigned when the value is the same.

<key> and <ref> 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 Basic Usage

Simply assign line numbers without any arguments.

$ cat data

T1 T2 T3

JPN Wilson_____ 26

JPN Hawking____ 27

JPN Newton_____ 27

JPN Tesla______ 30

USA BOB________ 25

USA GEORGE_____ 29

USA SAM________ 29

USA TOM________ 35

$ tagrank data

RANK T1 T2 T3

1 JPN Wilson_____ 26

2 JPN Hawking____ 27

3 JPN Newton_____ 27

4 JPN Tesla______ 30

5 USA BOB________ 25

6 USA GEORGE_____ 29

7 USA SAM________ 29

8 USA TOM________ 35

Example 2 Specify a "ref"

If you specify a reference field with "ref=<ref>" then when the

reference field value changes the line numbers are reset to 1.

$ tagrank ref=1 data

RANK T1 T2 T3

1 JPN Wilson_____ 26

2 JPN Hawking____ 27

3 JPN Newton_____ 27

4 JPN Tesla______ 30

1 USA BOB________ 25

2 USA GEORGE_____ 29

3 USA SAM________ 29

4 USA TOM________ 35

Example 3 Specify a "key"

You can specify a value field as "key=<key>".  In this case, records

where the key field has the same value are assigned the same line

number.  Line numbers are skipped so that the following lines are

numbered properly.

$ tagrank key=3 data

1 JPN Wilson_____ 26

2 JPN Hawking____ 27

2 JPN Newton_____ 27

4 JPN Tesla______ 30

5 USA BOB________ 25

6 USA GEORGE_____ 29

6 USA SAM________ 29

8 USA TOM________ 35

Example 4 Specifying both "ref" and "key"

When the reference key changes, line numbers are reset, and records

who share the same value field are assigned the same line number.

$ tagrank ref=1 key=3 data

RANK T1 T2 T3

1 JPN Wilson_____ 26

2 JPN Hawking____ 27

2 JPN Newton_____ 27

4 JPN Tesla______ 30

1 USA BOB________ 25

2 USA GEORGE_____ 29

2 USA SAM________ 29

4 USA TOM________ 35

Example 5 --tagname option

$ tagrank --tagname=LNO data

LNO T1 T2 T3

1 JPN Wilson_____ 26

2 JPN Hawking____ 27

3 JPN Newton_____ 27

4 JPN Tesla______ 30

5 USA BOB________ 25

6 USA GEORGE_____ 29

7 USA SAM________ 29

* If the input file is omitted or specified as "-" then the command will

  read from standard input.