Results 1 to 3 of 3
I have a text file with configuration information in the form:
Code:
etc
parameter1 some default text supplied by the vendor
etc
parameter2 some more default text
etc
What I ...
- 10-17-2008 #1Just Joined!
- Join Date
- Apr 2008
- Posts
- 5
Need to replace line of text.
I have a text file with configuration information in the form:
What I would like to do is replace the entire line with parameter1 with my own text. The problem is that I would like a solution that can match the line with "parameter1" as the first word on the line, but replace all of the text after it with something I provide. I could klugde something together with a Bash script and looping, but I was hoping for a more elegent solution, and I would rather not resort toCode:etc parameter1 some default text supplied by the vendor etc parameter2 some more default text etc
What I would like to have as output is:
Suggestions would be appreciated.Code:etc parameter1 my own text here etc parameter2 my other text here etc
Thanks.
- 10-17-2008 #2Linux Newbie
- Join Date
- Jan 2008
- Location
- UK
- Posts
- 211
Hi,
You can do this with Perl and it can be elegant depending on your skill or just write it in C.
Just a question, for such things why do you want elegance, if I may say so it is not doing anything complex and if it is for you just write it and refine it - play with it until it goes how you want in whatever language you are comfortable with.
wowbag1
- 10-17-2008 #3
You could probably do this in a single line of awk, but I'm feeling a bit too brain dead to figure it out right now (it's been a long day
)
Google about awk, and you should be able to figure out a solution quickly enough.Registered Linux user #388328 || Registered LFS user #15880
AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
Need instant help? Try us on IRC -- #linuxforums on freenode


Reply With Quote