grep

user@user:~$ grep -A 4 -B 7 "aaa" bbb.txt

在 bbb.txt 尋找 aaa 字串。

-A NUM : Print NUM lines of trailing context after matching lines.
-B NUM : Print NUM lines of leading context before matching lines.
-C NUM : Print NUM lines of output context.
這個相當於 -C NUM => -A NUM -B NUM

原文地址:https://www.cnblogs.com/youchihwang/p/6543353.html