find [搜索范围] [选项]
/home
目录下的 hello.txt 文件find /home -name hello.txt
/opt
目录下,用户名称为nobody的文件find /opt -user nobody
find / -size +200M
locate 搜索文件
updatedb
指令创建locate
数据库。locate
指令快速定位hello.txt
文件所在目录,找不到就不返回数据locate hell.txt
which Is
|
”,表示将前一个命令的处理结果输出传递给后面的命令处理。grep [选项] 查找内容 源文件
hello.txt
文件中,查找"yes
"所在行,并且显示行写法1:
cat /home/hello.txt | grep -n "yes"
写法2:
grep -n "yes" /home/hello.txt