grep 命令显示匹配规则的前后几行

Posted on Posted in command
grep -5 'parttern' file//打印匹配行的前后5行
 
grep -C 5 'parttern' file//打印匹配行的前后5行
 
grep -A 5 'parttern' file//打印匹配行的后5行
 
grep -B 5 'parttern' file//打印匹配行的前5行

Leave a Reply

Your email address will not be published. Required fields are marked *

six − 5 =