|
From: rickm on 17 Apr 2008 10:59 Im sure this one is very easy but I can get want Im after. I have a spice file that looks like this: ..subckt CKNXLVTD3 A ZN M_u2 ZN A VSS VSS nch_lvt w=2.88u l=0.13u M_u1 ZN A VDD VDD pch_lvt w=7.62u l=0.13u D60 VSS A ndio_lvt AREA=1.65e-13 PJ=1.7e-06 ..ends and it needs to look like this: ..subckt CKNXLVTD3 A ZN VSS VDD M_u2 ZN A VSS VSS nch_lvt w=2.88u l=0.13u M_u1 ZN A VDD VDD pch_lvt w=7.62u l=0.13u D60 VSS A ndio_lvt AREA=1.65e-13 PJ=1.7e-06 ..ends Basically, search for .subckt and append VSS and VDD to the line only. The line length can be long or short Thanks
From: Dave B on 17 Apr 2008 11:29 On Thursday 17 April 2008 16:59, rickm(a)galaxy.nsc.com wrote: > Im sure this one is very easy but I can get want Im after. I have a > spice file that looks like this: > > .subckt CKNXLVTD3 A ZN > M_u2 ZN A VSS VSS nch_lvt w=2.88u l=0.13u > M_u1 ZN A VDD VDD pch_lvt w=7.62u l=0.13u > D60 VSS A ndio_lvt AREA=1.65e-13 PJ=1.7e-06 > .ends > > and it needs to look like this: > > .subckt CKNXLVTD3 A ZN VSS VDD > M_u2 ZN A VSS VSS nch_lvt w=2.88u l=0.13u > M_u1 ZN A VDD VDD pch_lvt w=7.62u l=0.13u > D60 VSS A ndio_lvt AREA=1.65e-13 PJ=1.7e-06 > .ends > > Basically, search for .subckt and append VSS and VDD to the line > only. The line length can be long or short Uhm... sed 's/^\.subckt.*/& VSS VDD/' yourfile or awk '/^\.subckt/ {$0=$0" VSS VDD"}1' yourfile Is this what you want? -- D.
From: rickm on 17 Apr 2008 11:17 Yep, the both work!!!! Can you give a brief description how this works. I was only able to print the subckt line. What does the trailing "1" do on the awk solution? THANKS!!!!!! Rick On Apr 17, 8:29 am, Dave B <da...(a)addr.invalid> wrote: > On Thursday 17 April 2008 16:59, ri...(a)galaxy.nsc.com wrote: > > > > > Im sure this one is very easy but I can get want Im after. I have a > > spice file that looks like this: > > > .subckt CKNXLVTD3 A ZN > > M_u2 ZN A VSS VSS nch_lvt w=2.88u l=0.13u > > M_u1 ZN A VDD VDD pch_lvt w=7.62u l=0.13u > > D60 VSS A ndio_lvt AREA=1.65e-13 PJ=1.7e-06 > > .ends > > > and it needs to look like this: > > > .subckt CKNXLVTD3 A ZN VSS VDD > > M_u2 ZN A VSS VSS nch_lvt w=2.88u l=0.13u > > M_u1 ZN A VDD VDD pch_lvt w=7.62u l=0.13u > > D60 VSS A ndio_lvt AREA=1.65e-13 PJ=1.7e-06 > > .ends > > > Basically, search for .subckt and append VSS and VDD to the line > > only. The line length can be long or short > > Uhm... > > sed 's/^\.subckt.*/& VSS VDD/' yourfile > > or > > awk '/^\.subckt/ {$0=$0" VSS VDD"}1' yourfile > > Is this what you want? > > -- > D.
From: Dave B on 17 Apr 2008 11:45 On Thursday 17 April 2008 17:17, rickm(a)galaxy.nsc.com wrote: > Yep, the both work!!!! Can you give a brief description how this > works. I was only able to print the subckt line. > What does the trailing "1" do on the awk solution? > >> sed 's/^\.subckt.*/& VSS VDD/' yourfile This says to sed: when a line is like "^\.subckt.*", ie, starts with .subckt, then substitute that line with the whole line plus " VSS VDD". Since the -n switch is not specified, sed prints all lines. >> awk '/^\.subckt/ {$0=$0" VSS VDD"}1' yourfile This is the same logic applied to awk. Awk reads the file line by line. When a line is encountered that matches the regular expression ^\.subckt (that is, a line that begins with .subckt), then add " VSS VDD" at the end of that line. The "1" is an always-true condition that executes awk's default action, which is "print the whole line" (ie, $0). It's equivalent to: awk '/^\.subckt/ {$0=$0" VSS VDD"} 1 {print $0}' yourfile Note that any expression that awk evaluates as "true" could be used, like "hello" or 345. 1 just happens to be the more commonly used choice. -- D.
From: Bill Marcum on 17 Apr 2008 11:27 On 2008-04-17, rickm(a)galaxy.nsc.com <rickm(a)galaxy.nsc.com> wrote: > > > Im sure this one is very easy but I can get want Im after. I have a > spice file that looks like this: > > .subckt CKNXLVTD3 A ZN > M_u2 ZN A VSS VSS nch_lvt w=2.88u l=0.13u > M_u1 ZN A VDD VDD pch_lvt w=7.62u l=0.13u > D60 VSS A ndio_lvt AREA=1.65e-13 PJ=1.7e-06 > .ends > > and it needs to look like this: > > .subckt CKNXLVTD3 A ZN VSS VDD > M_u2 ZN A VSS VSS nch_lvt w=2.88u l=0.13u > M_u1 ZN A VDD VDD pch_lvt w=7.62u l=0.13u > D60 VSS A ndio_lvt AREA=1.65e-13 PJ=1.7e-06 > .ends > > Basically, search for .subckt and append VSS and VDD to the line > only. The line length can be long or short > > Thanks sed '/^\.subckt/s/$/VSS VDD/' file > newfile
|
Next
|
Last
Pages: 1 2 Prev: Replace symbols > and < with < and > Next: Help required:Awk Error |