Grep a string and write a value to next line of found string

Hi,
I have two variables x and y.
i need to find a particular string in a file, a workflow name and then insert the values of x and y into the next lines of the workflow name.
basically it is like as below

wf_xxxxxx
$$a=
$$b=
$$c= figo
$$d=bentley
i need to grep the 'wf_xxxx' and then write the values x and y to$$a and $$b.

Thanks in advance.

Try:

awk -F= '
/wf_xxxxxx/{
  print; getline; $(NF+1)=x;
  print; getline; $(NF+1)=y}
1' x="value1" y="value2" OFS="=" file > newfile

Hi franklin,
thanks for the reply.
can u pls explain this for my future reference.
also i want to write the values of x and y into $$a and $$b

here you go; setting x=12 and y=13 to test:

# x=12;y=13

# gawk -F"=" -v x=$x -v y=$y  '/wf_xxxxxx/{print;getline;print $0x;getline;print $0y;getline}1' /tmp/yourfilename

Sure:

awk -F= '				# field separator is "="
/wf_xxxxxx/{				# when the regexp is matched
  print; getline; $(NF+1)=x;		# print the line, get the next line and add x as last field
  print; getline; $(NF+1)=y}		# print the line, get the next line and add y as last field
1' x="value1" y="value2" OFS="=" file > newfile

Post an example of the input file and the desired output.

Hi Franklin,

The input values are x=21-10-1986 and y= 22-10-1986
so i need to check the particular wf name , wf_xxxx .
The param file format is like

[wf_xxxx]
$$startdate=
$$enddate=

i need to assign teh value of x and y to $$startdate and $$enddate.
hope i made myself clear to you.

---------- Post updated at 09:50 AM ---------- Previous update was at 09:48 AM ----------

Hi dude2cool,
Thanks a lot for your response.
Could you be little elaborate on the description.

thanks in advance.

gawk -F"=" -v x=$x -v y=$y      #Sets Field Separator to = and sets 2 
                                #variables to the values of x and y
 '/wf_xxxxxx/{                     #search for a line that has the pattern wf_xxxxxx
print;                              #print first line which is basically the line that    
                                          #contains wf_xxxxxx pattern
getline;                                # get next line
print $0x;                             # print the line with value of x
getline;print $0y;                   # repeat above for y
getline}1'   /tmp/yourfilename  # print rest of lines