Re: Need script to find the line which occurse after a given line



On 15 Feb 2006 22:42:18 -0800, mailursubbu@xxxxxxxxx wrote:
Hi,

I have file as below

Process= Proc1
{
Color=Red
Size=20
}

Process=Proc2
{
Color=Blue
Size=88
}

Now My script should take two parametes. ProcX and the property which
needs to be changed as below

Myscript Proc2 Color=Black
[...]

I would do it as:

perl -0777 -pi -e '
s/(Process\s*=\s*Proc2\s*\{.*?\sColor\s*=)[^\n]*/$1Black/s' file

That assumes there's a "Color" field in every "Process" entry.

--
Stephane
.



Relevant Pages