[Gllug] Help with sed

Christopher Mocock chris at wavestore.com
Thu Aug 20 12:21:11 UTC 2009


Hi,

I'm stuck with a little problem using sed to do some text substitution 
and was hoping someone on here could help... I've got a bit of text in a 
file like this:

[Lang_1]
Lang=en

The "en" could be anything and I want to replace it with another string. 
The input file could have "Lang=..." elsewhere so I need to replace only 
the Lang= line that follows "[Lang_1]".

The problem seems to be with the new line character after [Lang_1]. For 
example, I'd hoped I could do something like this:

NEWLANG=pt
cat inputfile | sed "s/$\[Lang_1\]\nLang=*^/\[Lang_1\]\nLang=$NEWLANG/"

I haven't refined that but it's the general idea I was trying. It's the 
newlines that seem to be the problem.

Any ideas or advice?

Thanks,

-- 
Chris
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list