linux四剑客
grep
查找文件内容
grep hello test.txt
在某个文件中查找包含hello的内容,只要一行中有hello会把整行显示grep -niv helle test.txt
n
显示查找到的内容行号,i
查找时不区分大小写,v
反向查找(查找不包含hello的行)grep -n hello home/admin -r
查找整个目录中的所有文件,包含hello的内容
find
查找文件
find /home -name 1.txt
在/home目录下查找文件名为1.txt的文件,输出文件路径find /home -name '*.txt'
在/home目录下查找所有后缀为.txt的文件。注意:如果查找模糊文件名,需对文件名参数加上引号。