grep -A 3 Ergo file.log 显示file.log文件中匹配Ergo字串的那行以及后3行
grep -B 3 Ergo file.log 显示file.log文件中匹配Ergo字串的那行以及前3行
grep -C 3 Ergo file.log 显示file.log文件中匹配Ergo字串的那行以及前后3行
若想要将过滤的内容重定向到指定的newfile.log文件:
grep -A 3 Ergo file.log > newfile.log
(newfile.log会自动生成,不用提前创建)
统计包含某个关键字的总个数
grep -o Ergo fileName | wc -l