2024年6月13日发(作者:)
在 Linux 系统中,find 命令是一个强大的文件搜索工具,用于
在指定目录及其子目录中查找文件。以下是 find 命令的常用用法示
例:
1、查找特定文件名:、
find /path/to/directory -name "filename"
这会在 /path/to/directory 目录及其子目录中查找名为
"filename" 的文件。
2、查找特定文件类型:
find /path/to/directory -type f
这会在 /path/to/directory 目录及其子目录中查找所有的普
通文件。
3、查找符合多个条件的文件:
find /path/to/directory -name "*.txt" -size +1M
这会在 /path/to/directory 目录及其子目录中查找文件名以
".txt" 结尾且大小大于 1MB 的文件。
4、排除特定目录:
find /path/to/directory -name "*.log" -not -path
"/path/to/directory/exclude/*"
这会在 /path/to/directory 目录及其子目录中查找 ".log"
文件,但排除 /path/to/directory/exclude/ 目录及其子目录。
5、执行操作:
find /path/to/directory -name "*.txt" -exec rm {} ;
这会在 /path/to/directory 目录及其子目录中查找 ".txt"
文件,并执行删除操作。


发布评论