cut的帮助信息和使用示例

选项选项2英文中文
-b–bytes=LISTselect only these bytes只选择这些字节
-c–characters=LISTselect only these characters只选择这些字符
-d–delimiter=DELIMuse DELIM instead of TAB for field delimiter使用DELIM代替TAB作为字段的分隔符
-f–fields=LISTselect only these fields;
also print any line that contains no delimiter character, unless the -s option is specified
只选择这些字段;如果不指定-s选项,程序也会打印不含分隔符的那些行
-nwith -b: don’t split multibyte characters和-b选项一起使用时,不分割多字符
–complementcomplement the set of selected bytes, characters or fields
-s–only-delimiteddo not print lines not containing delimiters如果某行不包含分隔符,那么就不打印它
–output-delimiter=STRINGuse STRING as the output delimiter.
the default is to use the input delimiter
使用STRING作为输出分隔符。默认使用输入分隔符
–helpdisplay this help and exit显示帮助信息并退出
–versionoutput version information and exit输出版本信息并退出

cut的部分帮助信息

[root@localhost ~]# cut --help
Usage: cut OPTION... [FILE]...
Print selected parts of lines from each FILE to standard output.
将每个FILE的行的被选中的部分打印到标准输出

...(略)...

Use one, and only one of -b, -c or -f.  Each LIST is made up of one
range, or many ranges separated by commas.  Selected input is written
in the same order that it is read, and is written exactly once.
对于参数 -b, -c, -f, 能且仅能使用它们中的一个. 每一个LIST是由一个范围组成,
或者由逗号分隔的许多个范围组成. 程序按照什么样的顺序读取input,
那么被选中的input也会按照什么样的顺序写入, 而且会精确的写入进去一次.

Each range is one of:(每个范围是下面中的一种)
  N     N'th byte, character or field, counted from 1
  N     第n个 字节/字符/字段, 从1开始计数.
  N-    from N'th byte, character or field, to end of line
  N-    从第N个字节/字符/字段开始, 到本行的结束.
  N-M   from N'th to M'th (included) byte, character or field
  N-M   从第N个字段到第M个字段(含第M个字段).
  -M    from first to M'th (included) byte, character or field
  -M    从第1个字段, 到第M个字段(含第M个字段).

With no FILE, or when FILE is -, read standard input.
如果没有FILE, 或者当FILE是 - 时, 就读取标准输入.

Report cut bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'cut invocation'
[root@localhost ~]#

示例

Usage: cut OPTION... [FILE]...
按空格识别字段,并展示第first~2个,第3个,第4~last个字段。
date | cut -d " " -f -2,3,4-
# 注意:分隔符必须是单个字符,你可以输入【date | cut -d ":," -f 1-】命令查看报错信息.
按空格识别字段,并展示第first~2个,第3个,第4~last个字段, 同时用TAB作为输出分隔符
date | cut -d ' ' -f -2,3,4- --output-delimiter='在这里输入TAB'
# 记得用引号把TAB引上. 输入TAB的方式:①输入组合键Ctrl+v ②按一下键盘上的TAB键
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值