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

 

 

魂内検索

DOCUMENTS

COMMAND

FORUM

UEC DOCS

VIDEO

 

Alphabetical list

(Video materials in preparation)

fldcmp(USP)

Name

fldcmp : Compares files field-by-field

Synopsis

Usage   : fldcmp [key=<key>] <file1> <file2>

Options : -a

          -l

          -e

          -s<c>

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

Edition : 1

Description

key=<key> 引数を省略すると全レコードが比較対象になります。指定した場

合は、キーの値が同じレコードのみが比較対象になります。この場合、キー

でソートされている必要が有ります。<key> としては以下を指定できます。

Compares <file1> to <file2> field-by-field.  If key=<key> is omitted,

all records are subject to compare.  Otherwise, only records which

have same key value are subject to compare.

<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

Outputs the first fields that differ in the following format and exits.

"Record No." Field No." "Value in <file1>" "Value in <file2>"

$ cat data1

0000000 Darwin______ 50 F 9x 59 20 7x 54

0000001 Newton______ 50 F 4x 3x 83 51

0000003 Wilson______ 26 F 30 50 71 36 30

$ cat data2

0000000 Darwin______ 50 F 91 59 20 76 54

0000002 Newton______ 50 F 46 39 83 51 21

0000003 Wilson______ 26 F 30 50 71

$ fldcmp data1 data2

1 5 9x 91

Example 2

If there are more than one set of fields that differ, displays all of the

fields that differ. If the field or record is missing on one side, then

it is displayed as "(Null)”.

$ fldcmp -a data1 data2

1 5 9x 91

1 8 7x 76

2 1 0000001 0000002

2 5 4x 46

2 6 3x 39

2 9 (Null) 21

3 8 36 (Null)

3 9 30 (Null)

4 1 (Null) 0000004

4 2 (Null) Kepler______

4 3 (Null) 40

4 4 (Null) M

4 5 (Null) 58

4 6 (Null) 71

4 7 (Null) 20

4 8 (Null) 10

4 9 (Null) 67

Example 3

You can add the file names to the start of each record.

$ fldcmp -a -l data1 data2

data1 data2 1 5 9x 91

data1 data2 1 8 7x 76

data1 data2 2 1 0000001 0000002

data1 data2 2 5 4x 46

data1 data2 2 6 3x 39

data1 data2 2 9 (Null) 21

data1 data2 3 8 36 (Null)

data1 data2 3 9 30 (Null)

data1 data2 4 1 (Null) 0000004

data1 data2 4 2 (Null) Kepler______

data1 data2 4 3 (Null) 40

data1 data2 4 4 (Null) M

data1 data2 4 5 (Null) 58

data1 data2 4 6 (Null) 71

data1 data2 4 7 (Null) 20

data1 data2 4 8 (Null) 10

data1 data2 4 9 (Null) 67

Example 4

Only compares records with matching keys. The files must be sorted on the key.

In this case, the record number for both <file1> and <file2> is displayed.

$ fldcmp -a -l key=1 data1 data2

data1 data2 1 1 5 9x 91

data1 data2 1 1 8 7x 76

data1 data2 3 3 8 36 (Null)

data1 data2 3 3 9 30 (Null)