用于在指定目录下查找文件和目录
| 实例 | 注释 |
|---|---|
| find /etc -name ".txt" -ls | 查找文件以列表的形式查看 |
| find /etc -iname ".txt" | 忽略大小写 |
| find /etc -size +5M(-5 5) | 查找大于5M的文件 |
| find /etc -mtime +5(-5 5) | 查找过去5天内被修改过的文件 |
| find /etc -atime +5(-5 5) | 查找过去5天内被读取过的文件 |
| find /etc -cmin +5(-5 5) | 查找过去5分组内被修改过的文件 |
| find /etc -maxdepth 2 -a -name ".txt" | 按照目录深度查找文件 |
| find /etc -name ".txt" -o -name ".txt" | -o 或者 -a 并且 |
| find /etc ! -name ".txt" | 除.txt外的目录和文件 ! 取反 |
| find /etc -type f | 查找路径下的文件(c-字型装置文件,b-区块装置文件) |
| find /etc -type d | 查找路径下的目录(p-具名贮列,l-符号连结) |
| find . -perm 644 | 查找当前目录下权限为644的文件和目录 |
| find /etc -name ".txt*" -exec cp -rvf {} /tmp \; | *查找路径下文件并复制到路径下 |
| find /etc -name ".txt" |xargs rm -rf | 整体删除 |
| find / -name "*.txt" -mtime -10 -type f -print | 10天以内被修改过的文件(内容修改时间 ctime 元数据) |
| ls -t /tmp/xx | 查看修改文件的时间并从最新排序 |
| find / -user xxx | 查找属于用户xx的文件 |