find

find start_directory test options criteria_to_match action_to_perform_on_results

 

-perm mode:文件许可正好符合mode

-perm +mode:文件许可部分符合mode

-perm -mode:文件许可至少符合mode

 

忽略某个目录:

如果在查找文件时希望忽略某个目录,那么可以使用-prune选项来指出需要忽略的目录。在使用-prune选项时要当心,因为如果你同时使用了-depth选项,那么-prune选项就会被find命令忽略。

例如:在/apps目录下查找文件,而不再/apps/bin目录下查找,可以用:

find /apps -path "/apps/bin" -prune -o -print

find ./ -path ./out -prune -o -name *AudioSystem.* -print
注意是"./out" 而非 "out"

 

-path 只是匹配find出来的路径,可以通过使用匹配符号* [] ?

 

避开数个文件夹:

find /usr/sam \(-path /usr/sam/dir1 -o -path /usr/sam/file1 \) -prune -o print

查找某一确定文件: -name 等选项加在 -o 子后

find /usr/sam \( -path /usr/sam/dir1 -o -path /usr/sam/file1 \) -prune -o -name "temp" -print

 

指定多个起始目录:

find /usr/home   /tmp  -name "*.c"

 

查找大于 10MB 的所有文件

find / ­size +10000k –xdev –exec ls –lh {}\;

 

The following command finds all the files not modified in the last 60 days

under /home/jsmith directory and creates an archive files under /tmp in the

format of ddmmyyyy_archive.tar.

# find /home/jsmith -type f -mtime +60 | xargs tar -cvf

/tmp/`date '+%d%m%Y'_archive.tar` 

 

posted on 2013-02-19 17:29  阿加  阅读(229)  评论(0编辑  收藏  举报

导航