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

posted @ 2014-04-24 08:47  CloudPing  阅读(145)  评论(0编辑  收藏  举报