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

 

 

魂内検索

DOCUMENTS

COMMAND

FORUM

UEC DOCS

VIDEO

 

Alphabetical list

(Video materials in preparation)

width (USP)

Name

width : Returns the display width of a file

Synopsis

Usage   : width [-vf] <file1> <file2>...

Version : Tue Jun 17 23:01:25 JST 2014

Description

Returns the display width of <file> using a single-byte character

as width 1. multi-byte characters are width 2.

You can specify multiple files.

Example 1

Returns the display width of the specified file

$ cat data

1234

東京

オオサカ

オオサカ

$ width data

4

8

Example 2

The -v option displays the line number where the display width changes.

$ hava -v data

1 4                   <--- Width is 4 characters from line 1

4 8                   <--- Width is 8 characters from line 4

Example 3

The -f option outputs the file name.

When reading from standard input, STDIN is displayed.

Can be used together with the -v option to display the file name,

line number and display width.

$ cat file1

1234

$ cat file2

abcdefg

$ width -f file1 file2

file1 4

file2 6

$ width -vf file1 file2

file1 1 4

file2 1 6

$ cat file1 | width -f - file2

STDIN 4

file2 6

Reference

$ cat data

1234

東京

オオサカ

$ awk '{print length($0)}' data   <-- Number of characters is displayed regardless

4                      of the byte size of the characters.

2

4

$ LANG=C awk '{print length($0)}' data <-- Number of bytes is returned

4

6

12