一:find指令

find指令将从指定目录向下递归地遍历其各个子目录,将满足条件的文件或者目录显示在终端

基本语法:

find [搜索范围] [选项]

选项说明:

-name:按照指定文件名查找文件 -- find / -name a.txt --/表示根目录

-- find / -name *.txt --/查找根目录下所有的txt文件

linux学习篇之find、locate、grep

-user:查找属于指定用户名所有文件 find /home -user root

linux学习篇之find、locate、grep

-size:按照指定文件大小查找文件(+n 大于 -n 小于 n 等于) find /opt -size +20M

linux学习篇之find、locate、grep

二:locat指令

linux学习篇之find、locate、grep

updatedb

locate a.txt

linux学习篇之find、locate、grep

三:grep指令和管道符号 |

linux学习篇之find、locate、grep

cat a.txt | grep -n 321 --查看a.txt含有321的内容在多少行

linux学习篇之find、locate、grep

grep -n aaa /home/a.txt --在home文件下的a.txt查找含有aaa字符的行数(区分大小写匹配aaa)

grep -ni aaa /home/a.txt --继上忽略大小写查找

linux学习篇之find、locate、grep

 

相关文章:

  • 2021-07-03
  • 2021-06-08
  • 2021-04-20
  • 2022-12-23
  • 2021-06-29
猜你喜欢
  • 2021-08-11
  • 2021-05-02
  • 2021-12-15
  • 2021-07-27
  • 2021-08-13
  • 2021-07-29
相关资源
相似解决方案