Code:
hostname=`grep $client zabbixhosts | cut -f2 -d:`
I tried to simulate your scenario in my linux machine. Assuming that your client variable contains <BaculaServer-fd >.
From the above code, variable hostname contains Server_Bacula if grep is successfull and will contain no value if it fails. Something like this....
Code:
$ cat zabbixhosts
Helpdesk-fd:Server_Helpdesk
Knowledge-fd:Server_Knowledge
BaculaServer-fd:Server_Bacula
Zabbix-fd:Server_Zabbix_1.4.2
$ echo $client
sai
$ hostname=`grep $client zabbixhosts | cut -f2 -d:` ; echo $hostname
$ client="BaculaServer-fd"
$ hostname=`grep $client zabbixhosts | cut -f2 -d:` ; echo $hostname
Server_Bacula
$ hostname=`grep -w $client zabbixhosts | cut -f2 -d:`; echo $hostname
Server_Bacula
|