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

 

 

魂内検索

DOCUMENTS

COMMAND

FORUM

UEC DOCS

VIDEO

 

Alphabetical list

(Video materials in preparation)

calc

Name

calc : Insert data or formula immediately after the specified field.

       wrapper for "awk" command

Synopsis

Usage   : calc '<awk_exp>' <f> <file>

Version : Thu Aug 28 15:19:46 JST 2014

Description

Inserts data or formula specified as an <awk_exp> (following

the grammar of the awk command) immediately after the <f>th field

in <file>, then executes awk.

Makes it easy to insert values in between fields that would be

difficult to write with awk.

Example 1

$ cat data

0000000 Smith______ 50 F 91 59 20 76 54

0000001 Jones______ 50 F 46 39 8  5 21

0000003 Wilson_____ 26 F 30 50 71 36 30

0000004 Drake______ 40 M 58 71 20 10 6

0000005 Hawking____ 50 F 82 79 16 21 80

$ calc '$5+$6+$7+$8+$9' 4 data

0000000 Smith______ 50 F 300 91 59 20 76 54

0000001 Jones______ 50 F 119 46 39 8 5 21

0000003 Wilson_____ 26 F 217 30 50 71 36 30

0000004 Drake______ 40 M 165 58 71 20 10 6

0000005 Hawking____ 50 F 278 82 79 16 21 80

The following awk command is equivalent to the above example.

$ awk '{print $1,$2,$3,$4,$5+$6+$7+$8+$9,$5,$6,$7,$8,$9}' data

Example 2

$ cat data

0000 Smith______

0001 Jones______

0003 Wilson_____

0004 Drake______

0005 Hawking____

$ calc '"M"' 1 data

0000 M Smith______

0001 M Jones______

0003 M Wilson_____

0004 M Drake______

0005 M Hawking____

The following awk command is equivalent to the above example.

$ awk '{print $1,"M",$2}' data