linux-查找相关-find-locate-grep

find-查找命令

 

根据文件名查找

find 查找范围(路径) 查找类型(-name)  搜索的词

[[email protected] ooo]$ find ./ -name abc.txt
linux-查找相关-find-locate-grep

 

根据文件的大 小查找

find 查找路径 查找类型(-size)文件大小

linux-查找相关-find-locate-grep

大于 +n
小于-n
等于 n

 

使用通配符按名称查找

linux-查找相关-find-locate-grep

 

 

 

 

locate查询文件

用法

locate 要搜索的文件

linux-查找相关-find-locate-grep

 

注意

首次使用前,先更新一下,使用root帐户更新

通过命令

updatedb

 

 

 

grep,在文件内部查找

用法

grep  需要查找的关键词  需要查找的文件 选项

linux-查找相关-find-locate-grep

 

选项

-n 显示行号

-i 忽略大小写,ignore

-ni

 

与管道的配合

管道符号 |

原始的用法

grep  需要查找的关键词  需要查找的文件 选项

grep pyhui abc.txt 

 

与管道相结合的用法

管道符号| 功能是,将左边的命令的结果内容 作为管道右边命令的数据源

其它指令 | grep 需要查找的关键词

cat abc.txt | grep pyhui

相当于

grep pyhui abc.txt