need a quick basic shell script help

im trying to run the below if command

ifconfig -a |grep 10.100.120.21

gives me below output
inet addr:10.100.120.21 Bcast:10.100.120.255 Mask:255.255.255.0

i just want a basic shell which says if above exists then continue

how would i do this?

#!/bin/sh

ifconfig -a |grep 10.100.120.21 
if test "$?" = "0"
then
     echo I found the address
else
     echo I did not find the address
fi

Hi Porter,
What OS is ` ifconfig -a ` used in, doesn't work for HP-UX.

thanks that worked -ifconfig -a is used to find ethernet addresses

Solaris, NetBSD, Linux ... it's fairly common. It does the command for all interfaces.

Cheers porter.
Thought I was missing something there for a moment. :wink:

[[ ! -z "$(ifconfig -a | grep 10.100.120.21)" ]] && echo Exists

:slight_smile: