find命令用来在指定目录下查找文件。任何位于参数之前的字符串都将被视为欲查找的目录名。如果使用该命令时,不设置任何参数,则find命令将在当前目录下查找子目录与文件。并且将查找到的子目录和文件全部进行显示。
一、命令格式:
find path -option [ -print ] [ -exec -ok command ] {} \;
	-print      将查找到的文件输出到标准输出 
-exec command {} \;      将查到的文件执行command操作,{} 和 \;之间有空格 
-ok      和-exec相同,只不过在操作前要询用户
二、常用参数
	===================================================== 
-name filename      #查找名为filename的文件 
-perm      #按执行权限来查找 
-user username      #按文件属主来查找 
-nouser      #查无有效属主的文件,即文件的属主在/etc/passwd中不存 
-group groupname      #按组来查找 
-nogroup      #查无有效属组的文件,即文件的属组在/etc/groups中不存在 
-mtime -n +n      #按文件更改时间来查找文件,-n指n天以内,+n指n天以前 
-atime -n +n      #按文件访问时间来查GIN: 0px”>
	-ctime -n +n      #按文件创建时间来查找文件,-n指n天以内,+n指n天以前 
-type b/d/c/p/l/f      #查是块设备、目录、字符设备、管道、符号链接、普通文件 
-size n[c]      #查    长度为n块[或n字节]的文件 
-depth      #使查找在进入子目录前先行查找完本目录
=====================================================
实例
1、根据文件或者正则表达式进行匹配
	在当前目录及子目录中,查找大写字母开头的txt文件 
find . -name '[A-Z]*.txt' -print
	在当前目录及子目录中,查找不是out开头的txt文件 
find . -name "out*" -prune -o -name "*.txt" -print
	基于正则表达式匹配文件路径 
find . -regex ".*\(\.txt|\.pdf\)$"
	打印test文件名后,打印test文件的内容 
find ./ -name test -print -exec cat {} \;
	不打印test文件名,只打印test文件的内容 
find ./ -name test -exec cat {} \;
	find . -type 类型参数 
类型参数列表: 
f     普通文件 
l      符号连接 
d     目录 
c     字符设备 
b     块设备 
s     套接字 
p     Fifo
	查找目录并列出目录下的文件(为找到的每一个目录单独执行ls命令,没有选项-print时文件列表前一行不会显示目录名称) 
find ./ -type d -print -exec ls {} \;
UNIX/Linux文件系统每个文件都有三种时间戳:
	访问时间(-atime/天,-amin/分钟):用户最近一次访问时间。 
修改时间(-mtime/天,-mmin/分钟):文件最后一次修改时间。 
变化时间(-ctime/天,-cmin/分钟):文件数据元(例如权限等)最后一次修改时间。
	搜索最近七天内被访问过的所有文件 
find . -type f -atime -7
	搜索恰好在七天前被访问过的所有文件 
find . -type f -atime 7
搜索超过七天内被访问过的所有文件
	find . -type f -atime +7 
文件大小单元:
	b —— 块(512字节) 
c —— 字节 
w —— 字(2字节) 
k —— 千字节 
M —— 兆字节 
G —— 吉字节
	搜索大于10KB的文件 
find . -type f -size +10k
	搜索小于10KB的文件 
find . -type f -size -10k
	搜索等于10KB的文件 
find . -type f -size 10k
	当前目录下搜索出权限为777的文件 
find . -type f -perm 777
	找出当前目录下权限不是644的php文件 
find . -type f -name "*.php" ! -perm 644
	找出当前目录用户tom拥有的所有文件 
find . -type f -user tom
	找出当前目录用户组sunk拥有的所有文件 
find . -type f -group sunk
	查找当前目录下所有.txt文件并把他们拼接起来写入到all.txt文件中 
find . -type f -name "*.txt" -exec cat {} \;> all.txt
	将30天前的.log文件移动到old目录中 
find . -type f -mtime +30 -name "*.log" -exec cp {} old \;
	在/ l o g s目录中查找更改时间在5日以前的文件并删除它们: 
$ find /logs -type f -mtime +5 -exec -ok rm {} \;
	在/tmp中查找所有的*.h,并在这些文件中查找“SYSCALL_VECTOR”,最后打印出所有包含”SYSCALL_VECTOR”的文件名 
find /tmp -name "*.h" -exec grep "SYSCALL_VECTOR" {} \; -print
	在当前目录,不再子目录中,查找txt文件 
find . ! -name "." -type d -prune -o -type f -name "*.txt" -print
	查找比aa.txt新的文件 
find . -newer "aa.txt" -type f -print
	查找aa.txt 并备份为aa.txt.bak 
find . -name 'aa.txt' -exec cp {} {}.bak \;
	查找aa.txt 归档压缩为aa.txt.tar.gz 并删除aa.txt 
find . -name "aa.txt" -type f -exec tar -zcvf {}.tar.gz {} \; -exec rm -rf {} \; > /dev/null
