统计a出现的次数
[[email protected] ~]# cat aa.txt
sdkasdas
asdkasda
ajdksa
aksldjkalsd
askdlaskd
asdjjaskjd
asdaskd
asdkaslkd
asdkalskdj
askdljalskd
kalsjdklasjd
alskdjalks
123456
解决方法:
1.grep -o ‘a‘ aa.txt | wc -l
2.awk -v RS=‘a‘ ‘END{print --NR}‘ aa.txt
3.cat aa.txt |tr -cd ‘a‘|wc -c
时间: 2024-11-01 04:33:01