您的位置:首页 > 其它

find grep组合使用查找文件

2010-10-11 12:17 281 查看
1. 查找所有".h"文件

find /PATH -name "*.h"


2. 查找所有".h"文件中的含有"helloworld"字符串的文件

find /PATH -name "*.h" -exec grep -in "helloworld" {} \;


3. 查找所有".h"和".c"文件中的含有"helloworld"字符串的文件

find /PATH /( -name "*.h" -or -name "*.c" /) -exec grep -in "helloworld" {} \;


4. 查找非备份文件中的含有"helloworld"字符串的文件

find /PATH /( -not -name "*~" /) -exec grep -in "helloworld" {} \;


注:
/PATH
为查找路径,默认为当前路径。带-exec参数时必须以\;结尾,否则会提示“find: 遗漏“-exec”的参数”。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: