在CentOS系统中,可以使用find
命令来查找文件。以下是一些常用的find
命令用法:
find /path/to/directory -type f
这里,/path/to/directory
是你要搜索的目录路径,-type f
表示只查找文件。
find /path/to/directory -type f -name "filename.ext"
将filename.ext
替换为你要查找的文件名。
find /path/to/directory -type f -iname "*.ext"
这里,*.ext
表示查找所有扩展名为.ext
的文件。-iname
选项表示不区分大小写。
find /path/to/directory -type f -name "*.ext" -exec rm -f {} \;
这将查找所有扩展名为.ext
的文件,并删除它们。请谨慎使用此命令,以免误删重要文件。
find /path/to/directory -type f -size +10M
这里,+10M
表示查找大于10MB的文件。你也可以使用-10M
(不包括10MB)或10M
(正好10MB)作为参数。
find /path/to/directory -type f -mtime -7
这里,-mtime -7
表示查找在过去7天内修改过的文件。你可以根据需要调整天数。
这些只是find
命令的一些基本用法。要了解更多关于find
命令的信息,请查阅其手册页(通过运行man find
)。