在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
)。