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

 

 

魂内検索

DOCUMENTS

COMMAND

FORUM

UEC DOCS

VIDEO

 

Alphabetical list

(Video materials in preparation)

count(USP)

Name

count :  Count the number of rows that contain the same key.

Synopsis

Usage   : count <k1> <k2> <file>

          count key=<key> <file>

Options : -e

          -s<c>

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

Edition : 1

Description

This tool outputs the number of rows (records) where the key fields

are the same value as the value specified in the file <file>.  The

key fields are specified using <k1> as the first field and <k2> as

the last field.  The the key fields should 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)

If <file> is ommitted or specified as "-", the standard input is

read.

Example 1

(Original Data)

$ cat data

01 Massachusetts 01 Boston 91 59 20 76 54

01 Massachusetts 02 Worcester 46 39 8 5 21

01 Massachusetts 03 Springfield 82 0 23 84 10

02 New_York 04 Manhattan 30 50 71 36 30

02 New_York 05 Brooklyn 78 13 44 28 51

02 New_York 06 Queens 58 71 20 10 6

02 New_York 07 Bronx 39 22 13 76 08

02 New_York 08 Albany 82 79 16 21 80

02 New_York 09 Buffalo 50 2 33 15 62

03 New_Jersey 10 Newark 52 91 44 9 0

03 New_Jersey 11 Trenton 60 89 33 18 6

03 New_Jersey 12 Moorestown 95 60 35 93 76

04 Pennsylvania 13 Philadelphia 92 56 83 96 75

04 Pennsylvania 14 Pittsburgh 30 12 32 44 19

04 Pennsylvania 15 Lancaster 48 66 23 71 24

04 Pennsylvania 16 Hershey 45 21 24 39 03

Outputs the number of cities in each state.

$ count 1 2 data > result

$ cat result

01 Massachusetts 3

02 New_York 6

03 New_Jersey 3

04 Pennsylvania 4