1. grep 命令介绍
grep 查找文件里符合条件的字符串,常与管道符|
、cat
、ps
一起使用;主要用于查找文件中符合条件的字符串、统计文件中符合条件的字符串行数、grep 不显示自身进程
2. grep 常用命令参数
-c
:统计符合字符串条件的行数-v
:显示不包括文本的所有信息
3. grep 常用命令
过滤test.txt文件中hello内容
grep hello test.txt
cat test.txt |grep hello
统计test.txt中hello内容的行数
grep -c hello test.txt
过滤jf进程信息
ps -ef|grep jf