【问题标题】:search through regex pattern in a file在文件中搜索正则表达式模式
【发布时间】:2023-01-30 23:19:03
【问题描述】:

我有一个包含以下格式数据的文件

abc {u_bit_top/connect_down/u_FDIO[6]/u_latch}
ghi {u_bit_top/seq_connect/p_REDEIO[9]/ff_latch
def {u_bit_top/connect_up/shift_reg[7]

我想在每一行的文件中搜索模式*bit_top*FDIO*和*bit_top*REDEIO*,如果找到模式则删除整行。 我想要输出为

def {u_bit_top/connect_up/shift_reg[7]

我确实像 sed "/bit_top/d;/FDIO/d;/REDEIO/d;" 一样使用 sed 但这删除了具有位顶和FDI和雷迪奥分别地。 我如何搜索上述模式并删除包含它的行。 Shell 或 TCL 任何东西都会有用。

【问题讨论】:

    标签: shell awk sed tcl


    【解决方案1】:

    你已经很接近了! ;)

    sed '/bit_top.*FDIO/d' input
    

    只需在 sed 中输入一个与您想要的匹配的正则表达式...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-09
      • 2014-12-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多