Linux基础(5)Linux常用文件搜索命令

Linux基础(1)Linux简介

Linux基础(2)VMware虚拟机系统安装

Linux基础(3)Linux常用文件处理命令

Linux基础(4)Linux常用权限管理命令

Linux基础(5)Linux常用文件搜索命令

Linux基础(6)Linux常用用户管理命令

Linux基础(7)Linux常用解压缩命令

Linux基础(8)Linux常用网络命令

Linux基础(9)Linux软件包管理

Linux基础(10)vi或vim常用的操作命令

1.1、文件搜索命令

1.1.1、文件搜索命令find

(1)find path -name xxx 根据文件名搜索(文件名精准搜索)
在这里插入图片描述

(2)find path -name xxx 使用通配符模糊搜索
在这里插入图片描述

(3)find path -name xxx??? 使用?匹配字符个数
在这里插入图片描述

(4)find path -iname xxx 根据文件名搜索不区分大小写
在这里插入图片描述

(5)find path -size +n 大于n,-n 小于n的文件,linux中1数据块=0.5k
在这里插入图片描述

(6)find path -user xxx 根据所有者查找
在这里插入图片描述

(7)find path -cmin/-amin/-mmin -xx 根据时间查找,其中参数含义如下:
在这里插入图片描述
在这里插入图片描述

(8)find path condition1 -a condition2 查找条件必须同时满足条件1和条件2
在这里插入图片描述

(9)find path condition1 -o condition2 查找条件只要满足条件1和条件2中的一个就可以
在这里插入图片描述

(10)find path -type f/d/l 根据文件类型查找
在这里插入图片描述

(11)find path -name init -exec/-ok ls -l {} ; 对查询到的结果做进一步的处理
在这里插入图片描述

-ok 可以用来对每个进行确认,这个一般用于比如查找文件并删除,因为删除动作都比较谨慎,所以这个时候就非常适合使用-ok来一个一个确认
在这里插入图片描述

(12)find path -inum xxx 根据节点查找文件,可以用于查找硬链接或者对一些非常特殊文件名的文件进行相关操作
在这里插入图片描述

1.1.2、其他搜索命令

(1)locate 搜索文件
如果没有安装locate 需要使用 yum install mlocate 进行安装
locate 自己维护了一个数据表,也就是并不是实时更新的,可以通过updatedb手动更新
在这里插入图片描述

(2)locate -i 搜索文件不区分大小写
在这里插入图片描述

(3) which 可以找到命令所在的位置
在这里插入图片描述

(4)whereis 也可以找到命令的位置
在这里插入图片描述

(5)grep 搜索文件内容
在这里插入图片描述

(6)grep -i 不区分大小写进行文件内容查询
在这里插入图片描述

(7)grep -v 查询文件内容排除指定的内容
在这里插入图片描述

(8)grep -v ^# 去除以#开头的注释行
在这里插入图片描述

Guess you like

Origin blog.csdn.net/redrose2100/article/details/121301168