find . -name "*.txt" -print 在当前目录中查.txt文件并显示
find . -name "[A-Z]*" -print 查以大写字母开头的文件
find . -name "[a-z][a-z][0--9][0--9].txt" -print 查以两个小写字母和两个数字开头的txt文件
find . -size +1000000c -print 查长度大于1Mb的文件
find . -size 100c -print 查长度为100c的文件
find . -size +10 -print 查长度超过期作废10块的文件(1块=512字节)
find . -name "host*" -print 查以host开头的文件
find . -name "ap*" -o -name "may*" 查找以ap或may开头的文件
find . -name "tom.txt" [!] -ftype vfat 查找名称为tom.txt且文件系统类型不为or为vfat的文件
find . -name "wa*" -type l 查找名为wa开头且类型为符号链接的文件
find . [!] -type d -print 查找非目录或者目录文件
find . -empty 查找大小为0的文件或空目录
find . -name "passwd*" -exec grep david {} \ 看是否存在david用户
find . -perm 755 -print -exec ls -l {} \ 查所有用户都可读写执行的文件
find . -name "tmp.txt" -exec cat {} \ 查找temp.txt文件并查看
find . -name "tmp.txt" -ok rm {} \ 查找temp.txt文件并删除
find . -mtime -2 在.下查最近两天内改动过的文件
find . -atime -1 查1天之内被存取过的文件
find . -mmin +60 在.下查60分钟前改动过的文件
find . -amin +30 查最近30分钟前被存取过的文件
find . -user david 列出.目录内属于用户david的文件或目录
find . -uid +501 列出.目录内用户的uid大于501的文件或目录
find . -group david 列出.组内为david的文件或目录
find . -gid 501 列出.组内id为501的文件或目录
Example:
Linux下Find与cp、rm结合的应用
--------------------------------------------------------------------------------
1.find and cp
find /home -name '*.conf'|xargs -I {} cp -r {} /home/conf/
2.find and rm
find /home -name 'test-file-*' | xargs rm -rf
other example
1.find . -mtime -1 -type f -exec ls -l {} \;
2.find /tmp -name "*.h" | xargs -n50 grep SYSCALL_VECTOR
3.find /tmp -name "*.h" -exec grep "SYSCALL_VECTOR" {} \;