Overwriting File

How to overwrite every time a particular portion of a file?

---------- Post updated at 02:16 PM ---------- Previous update was at 02:07 PM ----------

I have a file whose contents are something like:

Output of "apachectl fullstatus" command:
---------------------------------------------
---------------------------------------------
---------------------------------------------
---------------------------------------------
End of Output of "apachectl fullstatus" command
------------------
-------------------
--------------------
every thing else
---------------------------

I want to overwrite only the portion starting from "Output of" to "End of . . . .command" with the output of the "apachectl fullstatus" command run after a given interval of time.

---------- Post updated at 04:30 PM ---------- Previous update was at 02:16 PM ----------

Any help will be highly appreciated..

Hi,

How about storing the everything else part in a file called "endpart.txt".
Then do this.

apachectl fullstatus > final.txt
cat endpart.txt >> final.txt

I know that this is a way. But i wanted to this in a certain way(as specified in my post) because i have certain constraints.

This can be done thru a perl / shell script

Eg:- File 1 has all the contents
File 2 has the update contents

open file1 and when the lines matches replace it with file2 contents

HTH,
PL