sed/awk to remove double quotes " that are inside of curly braces {}
It would be easier with sed
:
sed -e :1 -e 's/\({[^}]*\)"\([^}]*}\)/\1\2/g; t1'
Or perl
:
perl -pe 's{\{.*?\}}{$& =~ s/"//gr}ge'
Note that it assumes there's no nested {...}
.
To handle nested {...}
, you can use perl
's recursive regexp capabilities:
perl -pe 's(\{(?:[^{}]++|(?0))*\})($& =~ s/"//gr)ge'
With sed
, working our way outwards to escape the inner {...}
s before removing the "
s:
sed 's/_/_u/g
:1
s/\({[^{}]*\){\([^{}]*\)}/\1_<\2_>/g; t1
:2
s/\({[^}]*\)"\([^}]*}\)/\1\2/g; t2
s/_</{/g; s/_>/}/g;s/_u/_/g'