我想使用find命令在文件中查找某个字符串,并希望同时查看查找结果和匹配行数。
例如,使用以下命令,我可以得到查找结果,但我不知道我得到了多少个匹配结果。
find . -name .history | xargs grep ls
输出为
ls -r
ls -R
ls
我期望的输出是这样的
ls -r
ls -R
ls
total match number: 3
如何获得预期的输出?
最佳答案
.... | awk '{ a+=1; print} END { print "total match number: " a}'
关于bash - 如何输出shell查找结果和匹配号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10425667/