如何使用 UNIX shell 计算一个字母在文本文件中出现的次数? [英] How can I use the UNIX shell to count the number of times a letter appears in a text file?
本文介绍了如何使用 UNIX shell 计算一个字母在文本文件中出现的次数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有几个文本文件,我想计算一个字母在每个文件中出现的次数?
I have a few text files and I'd like to count how many times a letter appears in each?
具体来说,我想使用 UNIX shell 来执行此操作,形式为:cat 文件 |....做事...
Specifically, I'd like to use the UNIX shell to do this, in the form of: cat file | .... do stuff...
有没有办法让 wc 命令来执行此操作?
Is there a way I can get the wc command to do this?
推荐答案
grep char -o filename | wc -l
这篇关于如何使用 UNIX shell 计算一个字母在文本文件中出现的次数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文