Operating System - Tru64 Unix
1752590 Members
2973 Online
108788 Solutions
New Discussion юеВ

Re: Usage of ECHO and grep commands

 
sammer
Advisor

Re: Usage of ECHO and grep commands

Hi Dennis,

I tried below way as you told,but i didnt get any output.

==========================================
set -A TELNET_HOST_ARR ${telnet_host_str}

telnet_host_str="alden porthos million athos moe moronica mullins 15.146.231.62 15.146.230.119"

target_system=groucho

ipaddress=$(nslookup ${target_system} |grep -p ${target_system} | grep Address | awk '{print $2}')

status=$(echo $telnet_host_str | grep $target_system | grep $ipaddress)

# echo $status

#
=========================================

Since i kept ipaddress value in telnet_host_str array so am expecting that ipaddress value as output in status variable.

If i keep target_system value in telnet_host_str array then i may expect that output in status variable..

So what i want is it should handle both situations apropriately..

So please help me in changing below code:-

status=$(echo $telnet_host_str | grep $target_system | grep $ipaddress)

Thanks,
Shammer


Dennis Handly
Acclaimed Contributor

Re: Usage of ECHO and grep commands

>I tried below way as you told,but i didn't get any output.

Do you want AND or OR for the two conditions?
See your other thread for OR.

>should handle both situations appropriately.

It seems like you want OR.
sammer
Advisor

Re: Usage of ECHO and grep commands

OK Thanks Dennis..