find命令格式:find [搜索范围][匹配条件]
-name 参数:按照名字查找
[[email protected] ~]# find /root -name test ###精确查找 /root/test /root/.cpan/build/Template-Toolkit-2.26-LlOKAK/t/test [[email protected] ~]# find /root -name test??###模糊查找 /root/.cpan/build/PadWalker-2.2-TvkCqL/t/test.t /root/.cpan/build/YAML-1.15-LasxIR/t/test.t /root/.cpan/build/Test-Differences-0.64-QP24fE/t/test.t /root/.cpan/build/Email-Sender-1.300028-u3FaFt/t/test.t /root/.cpan/build/Email-Reply-1.204-YAHruY/t/test.t [[email protected] ~]# find /root -name *test* ##模糊查找,查找含有test的单词 find: paths must precede expression: itest
-iname参数:按照不区分名字查找
[[email protected] ~]# find /root -iname test ###不区分大小写 /root/TEST /root/test
-size参数:按照尺寸查找
[[email protected] ~]# find /root -size 2048(数据块) ##等于1M [[email protected] ~]# find /root -size +2048 ##大于1M [[email protected] ~]# find /root -size -2048 ## 小于1M ####一个数据块=512字节=0.5KB ####1MB=1024KB=2048数据块
-user参数:按照所属用户查询
[[email protected] home]# find /home -user admin ##查询属于admin用户的文件
-group:按照所属组查询
同上
-amin:访问时间access
[[email protected] home]# find /home -amin +5 #### 大于5分钟时被访问的文件 [[email protected] home]# find /home -amin -5 #### 5分钟内被访问的文件
-cmin:文件更改属性change
用法同amin
-type:按照文件类型查找
[[email protected] ~]# find /root -type d ###directory 按照目录查询 [[email protected] ~]# find /root -type f ###file 按照文件查询 [[email protected] ~]# find /root -type l ###link 按照连接查询
-a:两条件同时满足
[[email protected] ~]# find /root -size +20480 -a -size -204800 ##查找同时满足大于10M小于100M的文件[[email protected] ~]# find /root -size +20480 -a -type f ##查找同时满足大于10M且类型为文件
-o:两个条件满足任意一个即可
用法同-a
-inum:根据节点进行搜索
[[email protected] ~]# find / -inum 1319562 find: `/proc/23352/task/23352/fd/5‘: No such file or directory find: `/proc/23352/task/23352/fdinfo/5‘: No such file or directory find: `/proc/23352/fd/5‘: No such file or directory find: `/proc/23352/fdinfo/5‘: No such file or directory /root/test
时间: 2024-10-17 16:57:16