linux中如何统计文本字符的总个数
作者:互联网
1、测试数据
[root@centos7 test3]# ls test.txt [root@centos7 test3]# cat test.txt deet dggh df
2、awk实现
[root@centos7 test3]# ls test.txt [root@centos7 test3]# cat test.txt deet dggh df [root@centos7 test3]# awk '{print length}' test.txt 4 4 2 [root@centos7 test3]# awk '{print length}' test.txt | awk 'BEGIN{sum = 0} {sum += $1} END {print sum}' 10
或者:
[root@centos7 test3]# ls test.txt [root@centos7 test3]# cat test.txt deet dggh df [root@centos7 test3]# paste -d "" -s test.txt deetdgghdf [root@centos7 test3]# paste -d "" -s test.txt | awk '{print length}' 10
标签:test3,文本,个数,centos7,awk,linux,test,txt,root 来源: https://www.cnblogs.com/liujiaxin2018/p/16147449.html