Some help for awk

Here is my problem:

i'm looking how to append at the end of a line a string.
I'm working on a script to insert a new machine in the hostexinfo.cfg of nagios.
Depending of what type of machine it is, it should be inserted at the right place:
my file looks like this:
[...]
define hostextinfo{
host_name samba,kastor,f87,c1105,solferino,sirdata,sirappli,tfc627,ulysse
icon_image linux40.jpg
vrml_image linux40.png
statusmap_image linux40.gd2
}

In fact, in order to determine where to insert the new server, it have a check on the "icon_image".
The input has decided the machine is a linux, so it should be added to the "host_name" line.
How can i achieve this?
I have an idea but very heavy... using cat -n hostextinfo, then a grep to get the line number. Then a expr to get the line number of the first "define hostextinfo" just before and the following "}". i'm sure there is easier!!!
Thanx for your help...

Jason

You can try for linux as,
#!/bin/sh
echo "Enter server name"
read server

awk '/icon_image/ { print $2 }' hostexinfo.cfg | grep -q 'linux'
if [[ $? -eq 0 ]]
then
LINUX=1
fi

while read line;
do
echo $line | grep -q 'host_name'
if [[ $? -eq 0 && $LINUX -eq 1 ]]
then
echo $line,$server
fi
done < hostexinfo.cfg > /tmp/newhostexinfo.cfg

# Safe usage
mv hostexinfo.cfg hostexinfo.cfg.old
mv /tmp/newhostexinfo.cfg hostexinfo.cfg

# exit
exit 0

hth.

Specify your requirement other type of server's. Where the input servername has to be inserted?

hth.