shell script to search a string and delete the content

Hi,
I've a shell script e.g.

#!/bin/bash
echo "Enter the next hop id"
read nhid
echo "enter the IP address"
read IP
echo "enter the interface name"
read name
echo "enter the enable/disable state"
read state
exit 0

now from this script i want to search strings in another (.cam)
file e.g. the cam file is

BEGIN
next hop id value nhid
IP address value 192.168.1.101
Interface name xyz
enable disable state 1
END

now i've to search for the string 'next hop id value' in this cam file then delete the values in front of this string untill a new line starts and then append the user input value stored in the variable in front of this string.
similarly for other fields.

like if previously the cam file is as above and the user input value for ip address is 111.111.111.111, interface name is abc and enable/disable state is 0. finally this cam file should become like this:

BEGIN
next hop id value nhid
IP address value 111.111.111.111
Interface name abc
enable disable state 0
END

can anyone help me out in this.....
Thanks in advance!!

Vikas

From the file shown, I'm assuming the values to be replaced, are the last in the record, otherwise they can easily be replaced with their actual location in
the record ( say $5, $8, $11...):

#!/bin/bash

read -p "Enter the next hop id:"           id
read -p "Enter the IP address: "           ip
read -p "Enter the interface name:"        intfc
read -p "Enter the enable/disable state:"  enab


awk -v id="$id" -v ip="$ip" -v int="$intfc" -v enb="$enab"  '/next hop id/    {$NF=id}
          						     /IP address/     {$NF=ip}
              						     /Interface/      {$NF=int}
            						     /enable disable/ {$NF=enb}1' file > file.$$ && mv file.$$ file

Thanks for your help. can u give me its logic plz?

thanks rubin for your support.
but somehow its not working. its happenning to delete all the content of the other file where i want to put the value.
& in fact, if i can make myself clear, i want to search a particular string(irrespective of its location in the other file) & then replace the conents in front of this particular string till a new line starts.
its not like appending the content in the end of file or appending something at a particular location.
Thanks a lot!!

From your explanation it's quite unclear what you're trying to achieve, and it also seems that your pre-conditions have changed.
Could you post your code, and your efforts so far ?

BTW to append to a file you can use the >> operator.

[...your code ...] >> file

Thanks Rubin for your response.
I've somehow arrived at a solution that is working for my requirement.

this is
sed "s/IPaddress .*/IPaddress $IP/g" my.cam>>my.cam.tmp && mv my.cam.tmp my.cam

& it searches the string 'IPaddress in the file my.cam from the existing script, deletes the contents after this string untill a new line starts and then appends the value of variable 'IP' in front of this string 'IPaddress'

this was the exact thing i wanted to achieve.

But,thanks for all your support.

Vikas

Glad that you've found the solution to your problem.

Welcome.