sed - Remove any text between two parameters not working properly -


i need remove data between , , ( , "," along it.

i'm using below command.

sed -i '/,/,/(/{//!d;s/ ,$//}' test1.txt 

cat test1.txt

create set table edw_extrc_tab.aver_med_clm_hdr_extrc

,no fallback , no before journal, no after journal, checksum = default, default mergeblockratio

( extrc_run_id integer not null,

current output

create set table edw_extrc_tab.aver_med_clm_hdr_extrc

,no fallback ( extrc_run_id integer not null,

expected output:

create set table edw_extrc_tab.aver_med_clm_hdr_extrc

( extrc_run_id integer not null,

what wrong here ? suggestions?

thanks in advance.

two approaches:

-- gnu sed approach:

sed -z 's/,[^(]*//' test1.txt 

-- gnu awk approach:

awk -v rs= '{ sub(/,[^(]+/,"",$0) }1' test1.txt 

the output:

create set table edw_extrc_tab.aver_med_clm_hdr_extrc ( extrc_run_id integer not null, 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -