如何削减选项-b和-c与国际化有所不同

时间:2014-09-02 08:36:31

标签: bash cut

`-b BYTE-LIST'
`--bytes=BYTE-LIST'
     Select for printing only the bytes in positions listed in
     BYTE-LIST.  Tabs and backspaces are treated like any other
     character; they take up 1 byte.  If an output delimiter is
     specified, (see the description of `--output-delimiter'), then
     output that string between ranges of selected bytes.

`-c CHARACTER-LIST'
`--characters=CHARACTER-LIST'
     Select for printing only the characters in positions listed in
     CHARACTER-LIST.  The same as `-b' for now, but
     internationalization will change that.  Tabs and backspaces are
     treated like any other character; they take up 1 character.  If an
     output delimiter is specified, (see the description of
     `--output-delimiter'), then output that string between ranges of
     selected bytes.

-c的说明:目前与`-b'相同,但国际化会改变这种情况。

我假设某些语言的国际化字符可能包含多字节字符,那时-c-b的行为会有所不同......正确吗?

1 个答案:

答案 0 :(得分:3)

是。我们来做一个测试:

$ cat a
200
bést
203
-Ümlaut
$ cut -b2-3 a
00
é           <---- é has 2 bytes
03
Ü           <---- Ü has 2 bytes
$ cut -c2-3 a
00
és
03
Üm