grep 基于关键字搜索

grep 'linux' /etc/passwd

搜索passwd文件下的包含linux的行

find / -user linux|grep Video

在用户为linux的根目录下搜房Video内容

netstat -tnpl|grep server

查询网络进程为server的数据

-i在搜索的时候忽略大小写

-n显示结果所在行数

-v输出不带关键字的行

-Ax输出包含结果所在行之后指定的行数

-Bx输出包含结果所在行之前指定的行数

grep -B3 linux /etc/passwd
原文地址:https://www.cnblogs.com/jiqing9006/p/3627083.html