1

I have tried this to replace the resis_test by m.gds by searching the key word LAYOUT_PRIMARY.

sed -e 's/\(LAYOUT PRIMARY\).*\1 /m.gds/' < FILE.ex > b

FILE.ex

LAYOUT PRIMARY "resis_test"
LAYOUT SYSTEM GDSII

DRC RESULTS DATABASE "resis_test.drc.results" ASCII 
DRC MAXIMUM RESULTS 1000
DRC MAXIMUM VERTEX 199
3

More secure

sed -e '/LAYOUT PRIMARY/s/resis_test/m.gds/' < FILE.ex > b
1

Try this :

 sed -e 's/\(LAYOUT PRIMARY\).*/\1 m.gds/'
                               ^^^

note the call to captured group in the replacement part, not in the source part.

0

Tested with Below command and it worked fine

command1:

awk '/LAYOUT PRIMARY/{print gsub("resis_test","m.gds",$0)}1' filename

command2:

sed '/LAYOUT PRIMARY/s/resis_test/m\.gds/g' filename

output

LAYOUT PRIMARY "m.gds"
LAYOUT SYSTEM GDSII

DRC RESULTS DATABASE "resis_test.drc.results" ASCII 
DRC MAXIMUM RESULTS 1000
DRC MAXIMUM VERTEX 199
  • 1
    Note that (as also seen in the other two answers), there's no need to escape the period in the replacement section of the s///. – Jeff Schaller Sep 16 '19 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.