cut 可以从文本文件或文本流中截取文本。
Voir Aussi: cat
root:# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c 4 Intel(R) Core(TM) i3-4030U CPU @ 1.90GHz root:# cat /proc/cpuinfo | grep name model name : Intel(R) Core(TM) i3-4030U CPU @ 1.90GHz model name : Intel(R) Core(TM) i3-4030U CPU @ 1.90GHz model name : Intel(R) Core(TM) i3-4030U CPU @ 1.90GHz model name : Intel(R) Core(TM) i3-4030U CPU @ 1.90GHz
基本语法
cut OPTION... [FILE]...
当没有 FILE 或 FILE 为 - 时,读取标准输入。
注意:长选项强制性自变量,对于短选项也是强制性的。
OPTION 选项
| 参数 | EN 解释 | 中文翻译 | Remarque |
|---|---|---|---|
| -b, --bytes=LIST | select only these bytes | 只选择这些字节 | |
| -c, --characters=LIST | select only these characters | 只选择这些字符 | |
| -d, --delimiter=DELIM | use DELIM instead of TAB for field delimiter | 使用 DELIM 而不是 TAB 作为字段定界符 | |
| -f, --fields=LIST |
select only these fields; also print any line that contains no delimiter character, unless the -s option is specified |
只选择这些字段; 还打印任何不包含定界符的行,除非指定 -s 选项 |
|
| -n | (ignored) | (忽略) | |
| --complement | complement the set of selected bytes, characters or fields | 补全选中字节、字符或字段的集 | |
| -s, --only-delimited | do not print lines not containing delimiters | 不打印不包含定界符的行 | |
| --output-delimiter=STRING | use STRING as the output delimiter the default is to use the input delimiter | 使用 STRING 作为输出定界符,默认使用输入定界符 | |
| -z, --zero-terminated | line delimiter is NUL, not newline | 行定界符为 NUL,而非换行符 | |
| --help | display this help and exit | 显示此帮助并退出 | |
| --version | output version information and exit | 输出版本信息并退出 |
只可使用 -b、-c 或 -f 其中之一。每个 LIST 由一个范围或由以逗号分隔的多个范围组成。
选中输入的写入次序与读取次序相同,且只写入一次。
每个范围是下列之一:
| 参数 | EN 解释 | 中文翻译 | Remarque |
|---|---|---|---|
| N | N'th byte, character or field, counted from 1 | 第 N 个字节、字符或字段,从 1 计数 | |
| N- | from N'th byte, character or field, to end of line | 从第 N 个字节、字符或字段到行尾 | |
| N-M | from N'th to M'th (included) byte, character or field | 从第 N 到第 M 个 (包括) 字节、字符或字段 | |
| -M | from first to M'th (included) byte, character or field | 从第一到第 M 个 (包括) 字节、字符或字段 |
| Fonction | Commande | 文字解释 | 示例 | 示例解释 |
|---|---|---|---|---|
| 帮助 | cut --help | 展示帮助信息 | ||
| Version | cut --version | 展示版本信息 |
版权声明: 本文为独家原创稿件,版权归 Logiciel Numérique Heureux ,未经许可不得转载。