Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > replacing with ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 2226 of 2234
Post > Topic >>

replacing with key->value table and at later location

by robin.vobruba@[EMAIL PROTECTED] May 1, 2008 at 07:27 AM

hello everyone!
I need to fix some things in a piece of generated code. I think it has
to be done with awk, as its a multi line thing, for which sed seems to
be bad. I have to replace some values in functions, according to the
function name. so basically i have the generated code file
(simplifyed):
[code]
blabla Name_2 blabla {
aaaa
bbbb
cccc
  blabla Value blabla
dddd
}


blabla Name_1 blabla {
tttt
wwww
ssss
cccc
  blabla Value blabla
ssss


blabla Name_3 blabla {
xxxx
qqqq
  blabla Value blabla
llll
}
[/code]

and a substitution map somehow like this (doesnt have ot be in this
form, as i have to write it manually anyway):
[code]
Name_1 Value_x
Name_2 Value_z
Name_3 Value_y
[/code]

The first appearance of Value that comes after Name_1 has to be
changed to read Value_x and so forth. It could be done with one awk
invocation for each substitution, that would not be a problem, as it
are only about 8 of them. The thing is, i have newer used awk (except
copy and paste).

thanks :-)




 3 Posts in Topic:
replacing with key->value table and at later location
robin.vobruba@[EMAIL PROT  2008-05-01 07:27:25 
Re: replacing with key->value table and at later location
pk <pk@[EMAIL PROTECTE  2008-05-01 18:35:34 
Re: replacing with key->value table and at later location
robin.vobruba@[EMAIL PROT  2008-05-01 15:49:20 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon May 12 3:50:16 CDT 2008.