首页 > 系统服务 > 详细

Linux 指令篇:文档编辑--cut

时间:2014-04-25 07:30:21      阅读:535      评论:0      收藏:0      [点我收藏+]

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

Linux 指令篇:文档编辑--cut,布布扣,bubuko.com

Linux 指令篇:文档编辑--cut

原文:http://www.cnblogs.com/CloudPing/p/3684448.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!