Linux:find命令使用

1、查找/var/logs目录中更改时间在7天前的普通文件

find /opt -type f -mtime +7 -exec ls -l {} \;

2、在当前目录下查找文件内容包含main的文件

root@kevin:/opt/d00148588# find . -print | xargs grep "main"
二进制文件 ./test 匹配
./test.c:int main()
root@kevin:/opt/d00148588# 

3、把查到的结果输出到文件中

root@kevin:/opt/d00148588# find . -print | xargs grep "main" > tmp.log
root@kevin:/opt/d00148588# ll
总用量 28
drwxr-xr-x 2 root root 4096 2012-09-13 22:26 ./
drwxr-xr-x 5 root root 4096 2012-03-03 16:06 ../
-rwxr-xr-x 1 root root 8517 2011-11-25 22:04 test*
-rw-r--r-- 1 root root  355 2011-11-25 22:04 test.c
-rw-r--r-- 1 root root   51 2012-09-13 22:26 tmp.log
root@kevin:/opt/d00148588# 
posted @ 2012-09-13 22:29  Socrates  阅读(323)  评论(0编辑  收藏  举报