cut 可以從文本文件或文本流中截取文本。
另請參閱: 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 解釋 | 中文翻譯 | 備注 |
|---|---|---|---|
| -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 解釋 | 中文翻譯 | 備注 |
|---|---|---|---|
| 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 個 (包括) 字節、字符或字段 |
| 功能 | 命令 | 文字解釋 | 示例 | 示例解釋 |
|---|---|---|---|---|
| 幫助 | cut --help | 展示幫助信息 | ||
| 版本 | cut --version | 展示版本信息 |
版權聲明: 本文為獨傢原創稿件,版權歸 樂數軟件 ,未經許可不得轉載。