寻觅生命中的那一片浅草......

grep递归查找子目录

第一个,这个是看别人脚本的,配合find实现,-maxdepth指定深度,如果查找到底,就把-maxdepth删掉
find /var/log/httpd/* -maxdepth 1 -type f -mtime +14 -print | egrep ‘.*\.gz$’ | xargs -r /bin/rm

第二个,也是别人脚本,粗糙点,原先我是用这个来查找当前目录的,修改为`ls -R`,可以递归查目录
for i in `ls -R`;do grep rpm $i; echo $i; done;

第三个,比较好用啊,grep当前目录和子目录里文件的内容

grep Notifications `find ./*`

尚无评论

发表评论

2024年五月
« 5月    
 12345
6789101112
13141516171819
20212223242526
2728293031