Linux 指令篇:文档编辑--cut
NAME
cut
- remove sections from each line of files
SYNOPSIS
cut OPTION... [FILE]...
DESCRIPTION
Print selected parts of lines from each FILE to
standard output.
Mandatory arguments to long options are mandatory for short options too.
-d,
--delimiter=DELIM
use DELIM instead
of TAB for field delimiter
-f,
--fields=LIST
select only these
fields; also print any line that contains no delimiter character,unless the
-s option is specified
-c, --characters=LIST
select only these characters
===========================================================================
e.g.1
[root@localhost tmp]# head -3
passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
[root@localhost tmp]# cut -d‘:‘ -f 3
passwd
0
1
2
[root@localhost tmp]# cut -d ‘:‘ -f 3-5
passwd
0:0:root
1:1:bin
2:2:daemon
[root@localhost tmp]# cut -d ‘:‘ -f 3,5
passwd
0:root
1:bin
2:daemon
[root@localhost tmp]# cut -c 1-10
passwd
root:x:0:0
bin:x:1:1:
daemon:x:2
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。