一. find 和 grep组合使用
1. 查找所有".h"文件
find /PATH -name "*.h"
2. 查找所有".h"文件中的含有"helloworld"字符串的文件
find /PATH -name "*.h" -exec grep -in "helloworld" {} \;
find /PATH -name "*.h" | xargs 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”的参数”。
1.2查看文件夹大小
du -h -max-depth=1
linux tips
原文:http://www.cnblogs.com/luoyanghero/p/5245846.html