我有一個文件,內容如下。我想編輯這個文件,以便無論何時在文件中看到LTPGY模式,然後在「set t table new $ m table」行之後,插入一個帶有「FOUND」內容的新行。如何在2個特定模式匹配後編輯一個Unix文件插入幾行
輸入文件如下: -
set ra [ 1 22 3 ] LTPGY
set a 0
set a1 1
set t [ table new $m table]
set a [ $t process_axis]
set a [ $t voltage_axis]
set ra [ 1 22 3 ] STPGY
set a 0
set a1 1
set t [ table new $m table]
set a [ $t process_axis]
set a [ $t voltage_axis]
set ra [ 1 22 3 ] LTPGY
set a 0
set a1 1
set t [ table new $m table]
set a [ $t process_axis]
set a [ $t voltage_axis]
set ra [ 1 22 3 ] STPGY
set a 0
set a1 1
set t [ table new $m table]
set a [ $t process_axis]
set a [ $t voltage_axis]
我所要的輸出是這樣的: -
set ra [ 1 22 3 ] LTPGY
set a 0
set a1 1
set t [ table new $m table]
FOUND
set a [ $t process_axis]
set a [ $t voltage_axis]
set ra [ 1 22 3 ] STPGY
set a 0
set a1 1
set t [ table new $m table]
set a [ $t process_axis]
set a [ $t voltage_axis]
set ra [ 1 22 3 ] LTPGY
set a 0
set a1 1
set t [ table new $m table]
FOUND
set a [ $t process_axis]
set a [ $t voltage_axis]
set ra [ 1 22 3 ] STPGY
set a 0
set a1 1
set t [ table new $m table]
set a [ $t process_axis]
set a [ $t voltage_axis]
這有點寬泛。你能指出輸出文件的樣子嗎?此外,分享您的嘗試也是一件好事 – fedorqui