linux 系统中如何统计文件列数
作者:互联网
1、测试数据
[root@centos79 test]# cat a.txt e r w i s g n c w d h x
2、awk
[root@centos79 test]# cat a.txt e r w i s g n c w d h x [root@centos79 test]# awk '{print NF}' a.txt 4 4 4 [root@centos79 test]# awk 'END{print NF}' a.txt 4
3、grep + wc -l
[root@centos79 test]# cat a.txt e r w i s g n c w d h x [root@centos79 test]# head -n 1 a.txt | grep -o " " | sed "1i xx" | wc -l 4
4、tr + wc -l
[root@centos79 test]# cat a.txt e r w i s g n c w d h x [root@centos79 test]# head -n 1 a.txt | tr " " "\n" | wc -l 4
标签:文件,wc,linux,cat,centos79,列数,test,txt,root 来源: https://www.cnblogs.com/liujiaxin2018/p/15059570.html