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