我有几个文本文件,我想计算每个字母出现多少次?
具体来说,我想使用UNIX shell来执行此操作,形式为:cat file | .... 做东西...
有没有办法让wc命令执行此操作?
Sil*_*ost 45
grep char -o filename | wc -l
Run Code Online (Sandbox Code Playgroud)
小智 13
另一种选择:
tr -d -C X <infile | wc -c
Run Code Online (Sandbox Code Playgroud)
其中X是您要计算的字符或字符串,infile是输入文件.