简体   繁体   English

在 apropos 命令中计算单词

[英]Counting words in a apropos command

I have this command apropos -l apple .我有这个命令apropos -l apple I want to count the word "apple" from the output of the command.我想从命令的 output 中计算“苹果”这个词。 I am a beginner in UNIX commands, and have an idea that I have to use grep or wc , but I'm not sure how.我是 UNIX 命令的初学者,并且知道我必须使用grepwc ,但我不确定如何使用。 Any help would be appreciated.任何帮助,将不胜感激。

apropos -l apple | grep -io apple

There are many options within grep that can help you meet your objective and the above is just an example. grep 中有许多选项可以帮助您实现目标,以上只是一个示例。

Take the output of apropos -l and then pipe through to grep.取 apropos -l 的 output 然后 pipe 到 grep。 With grep, we search for all "apple" entries with -i to show any case combinations.对于 grep,我们使用 -i 搜索所有“apple”条目以显示任何大小写组合。 We then finally output the generated list through to wc -l to count the lines and therefore the entries,然后我们最后将 output 生成的列表通过 wc -l 来计算行数,从而计算条目,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM