Reputation: 339
I have a text file. I wanted to remove VDD,VDDG,VSS only if a line starts with .subckt. Becuase the other lines also have VDD,VDDG,VSS
I know a simple SED command to replace a matched word as shown below, but in this case, I only wanted to remove if a line starts with .subckt. Please provide any feedback. It would be a great help to me. Thank you in advance.
sed 's/VDD/ /' test.txt
test.txt:
.subckt AO22X2_RVT A1 A2 A3 A4 VDD VSS Y
MN1 net2 A2 VSS VSS n105 w=0.28u l=0.03u nf=1.0 m=1
MN3 net4 A4 VSS VSS n105 w=0.28u l=0.03u nf=1.0 m=1
MN5 Y net3 VSS VSS n105 w=0.42u l=0.03u nf=1 m=2
MN4 net3 A3 net4 VSS n105 w=0.28u l=0.03u nf=1.0 m=1
MN2 net3 A1 net2 VSS n105 w=0.28u l=0.03u nf=1.0 m=1
MP4 net3 A3 net1 VDD p105 w=0.54u l=0.03u nf=1.0 m=1
MP1 net1 A2 VDD VDD p105 w=0.54u l=0.03u nf=1.0 m=1
MP2 net1 A1 VDD VDD p105 w=0.54u l=0.03u nf=1.0 m=1
MP5 Y net3 VDD VDD p105 w=0.8u l=0.03u nf=1 m=2
MP3 net3 A4 net1 VDD p105 w=0.54u l=0.03u nf=1.0 m=1
.ends AO22X2_RVT
.subckt AOINVX4_RVT A VDD VDDG VSS Y
MN0 Y A VSS VSS n105 w=0.31u l=0.03u nf=1 m=4
MP0 Y A VDDG VDDG p105 w=0.80u l=0.03u nf=1 m=4
.ends AOINVX4_RVT
.
.
.
Upvotes: 0
Views: 115
Reputation: 4043
Here's the awk
solution,
awk '/^\.subckt/{gsub(/VDD|VDDG|VSS/,"")}1' file
Upvotes: 2
Reputation: 2128
That's what I come up with:
sed '/^\.subckt/ {s/VDD//; s/VDDG//; s/VSS//; }'
Upvotes: 0