Find命令 📝发布:2024-03-27 概述 指令 find pathname -options [-print -exec -ok ...] 查找文件 # 基本用法 find pathname -options [-print -exec -ok ...] # 查找当前目录后缀为 .log 的文件 find . -name "*.log" # 查找当前目录下过去两天内被访问过的所有文件 # -atime n 中的 n 是以“天”为单位的整数. # -n 表示“小于 n 天前”被访问过. # +n 表示“超过 n 天前”被访问过. # n 表示“正好 n 天前”被访问过. find . -atime -2 # 查找 /var/log 下过去两天内被访问过的日志文件 find /var/log -name "*.log" -atime -2 查找目录 # 查找当前目录及子目录中名为 config 的目录. # -type d: 查找目录. find . -type d -name "config" # 只查找当前目录下名为 config 的目录,而不进入子目录. find . -maxdepth 1 -type d -name "config" # -iname: 忽略目录大小写. find . -type d -iname "config" 参考链接 详解 find 命令