I need help on script which will find particular value from one file and replace it in another file( very urgent) : I have 2 files. (file ABC and file XYZ).
Few contents of ABC:

X_deb:  step # : 9
X_deb:  in  : 4'b0000
X_deb: out : 4'b1110
X_deb: load (4 , 4'b1010)
X_deb: MK : 4'b1111

X_deb:  step # : 10
X_deb:  in  : 4'b0100
X_deb: out : 4'b1001
X_deb: load (4 , 4'b1100)

X_deb:  step # : 11
X_deb:  in  : 4'b0001
X_deb: out : 4'b1100
X_deb: load (4 , 4'b1011)
X_deb: MK : 4'b1110
------------------------------

Contents of file XYZ:

X_step_9 4 4'b1010 ( 4'b1110)
X_step_10 4 4'b1100 (4'b1001)
X_step_11 4'b1011 (4'b1100)

-------------
Format syntax of file XYZ
X_step_# <load value for the step from ABC file> (if MK is present for the step then mk value for the step otherwise out value for that step from ABC file. ) 
..
But whatever scripts I am using, it is having some issues and not able to grep MK value for the step and put it in XYZ file instead of that it is putting "out" value for all the steps.
And unfortunately I deleted that script. 
NOTE: in ABC file, not all steps have MK value.(in above example only step 9 and 11 have MK value). 

Now I need to create one generic script for all the steps (in any language) which can do below things:( there are many steps, not only 9,10,11)
-it will grep MK value for particular step from ABC file.
-after that it will grep for that step in XYZ file (X_step_#) and replace "out" value with MK value.
. For example :. Script will find MK value for step 9 from ABC and then it will search for X_step_9 in XYZ file and replace "out" value with MK value.

Someone please help me on this. It is very very critical and urgent. 


