首页 > 系统服务 > 详细

linux tips

时间:2016-03-05 21:39:48      阅读:149      评论:0      收藏:0      [点我收藏+]
一. 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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!