linux系统中逐行统计某一字符出现的次数

1、测试数据

[root@centos79 test]# cat a.txt
a g a d g
d a d g
d g e g d
a a a a
d g d a a
[root@centos79 test]# awk -F "a" '{print NF - 1}' a.txt  ## 统计每行a出现的次数
2
1
0
4
2
原文地址:https://www.cnblogs.com/liujiaxin2018/p/14970506.html