首页 > 系统服务 > 详细

Linux命令之 wc cut

时间:2015-05-08 20:27:27      阅读:371      评论:0      收藏:0      [点我收藏+]

#wc  -[cmlLw]

选项和参数

       -c, --bytes

              统计字节数

       -m, --chars

              统计字符数

       -l, --lines

             统计行数

       -L, --max-line-length

              最长行的字符数

       -w, --words

              统计单词数

例子:

root@localhost:~/shell# cat file

Massachusetts

Virginia

Tulsa

Falls

Massachusetts

Virginia

View

Massachusetts

view


root@localhost:~/shell# wc -c file 

82 file

root@localhost:~/shell# wc -m file 

82 file

root@localhost:~/shell# wc -L file 

13 file

root@localhost:~/shell# wc -w file 

9 file


#cut  -[cdf]

       -c n-m

              选择从开头算起的n-m个字符

       -d ‘分隔符‘

              以‘分隔符‘为标记将行分隔为一个个字段(域)

        -f N

                和-d选项一起用,选定第N个字段(域)


例子:

root@localhost:~/shell# cat test 

View Bayshore 334

Massachusetts 6th 73


#-c选项指定的范围有三种:N,只取第N个字符; N-,第N个字符开始到行末尾; N-M,第N个字符到第M个字符间的所有字符

root@localhost:~/shell# cat test | cut -c 2

i

a

root@localhost:~/shell# cat test | cut -c 2-

iew Bayshore 334

assachusetts 6th 73

root@localhost:~/shell# cat test | cut -c 2-3

ie

as


#-d ‘ ‘, 以空格作为分隔符将每一行分隔为3个字段(域); -f N, 选取第N个域的字段

root@localhost:~/shell# cat test | cut -d ‘ ‘ -f 1

View

Massachusetts

root@localhost:~/shell# cat test | cut -d ‘ ‘ -f 2

Bayshore

6th




Linux命令之 wc cut

原文:http://poollooq.blog.51cto.com/8663272/1649694

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