国际化后剪切选项 -b 和 -c 有何不同

Ank*_*wal 4 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.
Run Code Online (Sandbox Code Playgroud)

说明-c目前与“-b”相同,但国际化将改变这一点。

我假设某些语言的国际化字符可能具有多字节字符,这就是何时-c表现-b不同......正确吗?

fed*_*qui 6

是的。我们来做个测试:

\n\n
$ cat a\n200\nb\xc3\xa9st\n203\n-\xc3\x9cmlaut\n$ cut -b2-3 a\n00\n\xc3\xa9           <---- \xc3\xa9 has 2 bytes\n03\n\xc3\x9c           <---- \xc3\x9c has 2 bytes\n$ cut -c2-3 a\n00\n\xc3\xa9s\n03\n\xc3\x9cm\n
Run Code Online (Sandbox Code Playgroud)\n