1. ignor case
[root@server tmp]# find . -type f -iname "bitops*"
2. or search
注意括号前后的空格
[root@server tmp]# find . -type f \( -iname "bit*" -o -iname "pass*" \) -print
3. 指定路径查询
[root@server tmp]# find /tmp -path '*etc*'
4. 正则查询
还有iregex
find . -regex ".*\(\.py\|\.sh\)$"
5. 反查
[root@server test]# find . ! -name '*.jpg'
6. 查询深度
[root@server tmp]# find . -maxdepth 2 -name '*.jpg'
./test/next.jpg
文件类型
File type | Type argument |
---|---|
Regular fle | f |
Symbolic link | l |
Directory | d |
Character special device | c |
Block device | b |
Socket | s |
Fifo | p |
7. 查询时间
查询7天以内访问过的文件
[root@server tmp]# find . -type f -atime -7
arg | arg | desc |
---|---|---|
| amin | accesstime |
| cmin | createtime |
| mmin | modifytime |
8. 大小查询
[root@server tmp]# find . -type f -size +2M |xargs ls -alh
[root@server tmp]# find . -type f -size +2M -exec ls -al {} \;
9. 查询并删除
[root@server test]# find . -name '*.txt' -delete
10. 权限查询
-perm mode:文件许可正好符合mode
-perm +mode:文件许可部分符合mode
-perm -mode: 文件许可完全符合mode
[root@server tmp]# find . -perm 001 | xargs ls -al