简体   繁体   English

OSX:列出包含Author:XXXX的文件,然后对它们进行grep以查找它们具有多少种方法

[英]OSX : list files that contains Author:XXXX then grep them to find how many methods they have

I am trying to come up with script that will find how many methods/functions are in files written by specific developers. 我正在尝试提出一个脚本,该脚本将查找特定开发人员编写的文件中有多少种方法/函数。

For example I want to filter down files that contains Author:XXXXXX then I want to search them to see how many instances the contain -(void)test (count the lines that start with or list the lines) 例如,我想过滤掉包含Author:XXXXXX的文件,然后我要搜索它们以查看包含-(void)test的实例数(计数以开头的行或列出行)

Thanks 谢谢

One possible solution: 一种可能的解决方案:

for F in $(grep -l Author *.txt); do echo $F; grep -c void $F; done

You might want to put some quote marks in various places to protect the file names from expansion... 您可能想要在各个位置加上一些引号,以防止文件名扩展。

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

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