用于模式替换的 Unix 文件编辑

用于模式替换的 Unix 文件编辑

我有一个包含重复模式的文件,如下所示:

set m [ meas new $proj rajesh  ]
meas $m set_type lvf_timing
abcde erft 1213
234 456 897 00000000000000
once upon a time 

set t [ table new $m pvbt_table ]
table $t set_region_set_name lvf_clusters
table $t set_instance_condition derate_instance_condition
table $t set_corner_condition derate_corner_condition
set a [ axis new $t parameter_axis CPS]
set a [ axis new $t parameter_axis RPB]
set a [ axis new $t parameter_axis periphery_Vt]
set a [ axis new $t process_axis]
set a [ axis new $t voltage_axis]
set a [ axis new $t temperature_axis]
set a [ axis new $t bias_axis vdda]

set t [ table new $m table ]
table $t set_equation {derate_equation pvbt_table}
table $t set_region_set_name lvf_clusters
table $t set_corner_condition derate_corner_condition
set a [ axis new $t parameter_axis CPS]
set a [ axis new $t parameter_axis RPB]
set a [ axis new $t parameter_axis periphery_Vt]
set a [ axis new $t process_axis]
set a [ axis new $t voltage_axis]
set a [ axis new $t temperature_axis]
set a [ axis new $t bias_axis vdda]

我希望处理该文件,以便所有此类模式都得到如下修改:

set m [ meas new $proj rajesh  ]
meas $m set_type lvf_timing
abcde erft 1213
234 456 897 00000000000000
once upon a time 

set t [ table new $m table ]
table $t set_region_set_name lvf_clusters
table $t set_corner_condition derate_corner_condition
set a [ axis new $t parameter_axis CPS]
set a [ axis new $t parameter_axis RPB]
set a [ axis new $t parameter_axis periphery_Vt]
set a [ axis new $t process_axis]
set a [ axis new $t voltage_axis]
set a [ axis new $t temperature_axis]
set a [ axis new $t bias_axis vdda]

答案1

你需要这样的东西:

sed '/table new.*pvbt_table/, /^$/d;/pvbt_table/d' input_file

相关内容