统计文件里面特定字符串出现次数

有三种方法:

1.

grep -o '字符串' file | wc -l

2.

awk -v RS="@#$j" '{print gsub(/字符串/,"&")}' file

3.

awk'{s+=gsub(/字符串/,"&")}END{prints}'file

相关推荐