Find 命令的一般形式为:find pathname -options [-print -exec -ok]
find命令的选项:
-name 按照文件名查找文件,如:find /etc -name "host*" -print | xargs >/tmp/host.log
-perm 按照文件权限来查找文件,如:find . -perm 755 -print
-user 按照文件属主来查找文件,如:find ~ -user dave -print
-group 按照文件所属的组来查找文件,如:find /apps -group beijing -print
-nouser 查找无有效属主的文件, 如:find / -nouser -print
-nogroup 查找无有效所属组的文件,如:find / -nogroup -print
-size n[c] 查找文件长度为n块的文件,带有c时表示文件长度以字节计,如:find /home/apache -size 100c -print
-depth 在查找文件时,首先查找当前目录中的文件,然后再在其子目录中查找
-fstype 查找位于某一类型文件系统中的文件,这些文件系统类型通常可以在配置文件/etc/fstab中找到,该配置文件中包含了本系统中有关文件系统的信息
-mount 在查找文件时不跨越文件系统mount点,如:find . -name "*.XC" -mount -print
-follow 如果find命令遇到符号链接文件,就跟踪至链接所指向的文件
-cpio 对匹配的文件使用cpio命令,将这些文件备份到磁带设备中
-newer file1 ! file2 查找更改时间比文件file1新但比文件file2旧的文件,如:假设现在的时间是23:40,希望查找更改时间在两个小时以内的文件, touch -t 07212140 dstamp, find . -newer dstamp -print
-mtime -n +n 按照文件的更改时间来查找文件,如: find / -mtime -5 -print (在系统根目录下查找更改时间在5日以内的文件)
-type 查找某一类型的文件(b - 块设备文件;d - 目录;c - 字符设备文件;p - 管道文件; l - 符号链接文件f - 普通文件),如:find /etc -type d -print -exec ls -l {} /;