如何中断作为grep C1输出的行

问题描述

-----我的输入文件[文件名-测试]

    centos is my bro
    red hat is my course
    ubuntu is my OS
    fqdn is stupid 

    tom outsmart jerry   
    red hat is 3
    red hat is friend
    red hat is my boy
    jerry is small

----我的代码

#! /bin/bash

grep -C1   --color=always "red hat" test
 

-预期输出

 centos is my bro
 red hat is my course
 ubuntu is my OS     
 --
 tom outsmart jerry   
 red hat is 3
 red hat is friend
 --
 red hat is 3
 red hat is friend
 red hat is my boy
 --
 red hat is friend
 red hat is my boy
 jerry is small

----即将输出

    centos is my bro
    red hat is my course
    ubuntu is my OS
    --
    tom outsmart jerry   
    red hat is 3
    red hat is friend
    red hat is my boy
    jerry is small

----请为grep命令提供必要的选项,以获取预期的输出

-----如果还有其他方法可以实现此输出

-----请在代码中提供参考和注释

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)