您的位置:首页 > 运维架构 > Linux

学习Linux命令之 wc cut

2015-05-08 18:20 465 查看
#wc -[cmlLw]选项和参数 -c, --bytes 统计字节数 -m, --chars 统计字符数 -l, --lines 统计行数 -L, --max-line-length 最长行的字符数 -w, --words 统计单词数例子:root@localhost:~/shell# cat fileMassachusettsVirginiaTulsaFallsMassachusettsVirginiaViewMassachusettsview
root@localhost:~/shell# wc -c file 82 fileroot@localhost:~/shell# wc -m file 82 fileroot@localhost:~/shell# wc -L file 13 fileroot@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 334Massachusetts 6th 73
#-c选项指定的范围有三种:N,只取第N个字符; N-,第N个字符开始到行末尾; N-M,第N个字符到第M个字符间的所有字符root@localhost:~/shell# cat test | cut -c 2iaroot@localhost:~/shell# cat test | cut -c 2-iew Bayshore 334assachusetts 6th 73root@localhost:~/shell# cat test | cut -c 2-3ieas
#-d ' ', 以空格作为分隔符将每一行分隔为3个字段(域); -f N, 选取第N个域的字段root@localhost:~/shell# cat test | cut -d ' ' -f 1ViewMassachusettsroot@localhost:~/shell# cat test | cut -d ' ' -f 2Bayshore6th
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: