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

 

 

魂内検索

DOCUMENTS

COMMAND

FORUM

UEC DOCS

VIDEO

 

Alphabetical list

(Video materials in preparation)

comma(USP)

Name

comma : Formats the specified field with commas every 3rd/4th digit.

Synopsis

Usage   : comma [+<n>h] [-4] <f1> <f2> ... <file>

          comma -d[4] <string>

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

Edition : 1

Description

Inserts commas after every 3rd/4th digit in the numeric text data

specified in the argument or the input file <file>.  The field to be

formatted is specified as arguments.

Example 1

$ cat data

20060201 296030 6710000

20060202 1300100 3130000

20060203 309500 20100

20060204 16300 300100

20060205 41000 210000

20060206 771100 400000

$ comma 2 3 data

20060201 296,030 6,710,000

20060202 1,300,100 3,130,000

20060203 309,500 20,100

20060204 16,300 300,100

20060205 41,000 210,000

20060206 771,100 400,000

Commas every fourth digit:

$ comma -4 2 3 data

20060201 29,6030 671,0000

20060202 130,0100 313,0000

20060203 30,9500 2,0100

20060204 1,6300 30,0100

20060205 4,1000 21,0000

20060206 77,1100 40,0000

Example 2

If you use the "+h" option then the first row is considered a header

and is ignored.  You can specify the starting row by number. +2h or

+3h would begin inserting commas starting with the second or third

row, respectively.

(Source Data : First row is a header)

$ cat data

Date Revenues Orders

20060201 296030 6710000

20060202 1300100 3130000

20060203 309500 20100

20060204 16300 300100

20060205 41000 210000

20060206 771100 400000

Insert commas ignoring the first row.

$ comma +h 2 3 data > data2

$ cat data2

Date Revenues Orders

20060201 296,030 6,710,000

20060202 1,300,100 3,130,000

20060203 309,500 20,100

20060204 16,300 300,100

20060205 41,000 210,000

20060206 771,100 400,000

Example 3

Insert commas into a numeric string specified directly as an

argument.

$ comma -d 1234567

1,234,567

$ comma -d4 1234567

123,4567

Note 1

Once you format a data file using comma command, you can no longer

perform numerical operations on that data using sm2, divk or other

numerical commands.  Only format numbers with comma command after

you have completed all calculations and are formatting the data for

output.

Note 2

Commas are not added after the decimal point.

Negative values are handled correctly.