Hallo,
I need to test a String (a special ip number-string).
So I want to run that:
ipadress=172.0.0.0
# for debugging:
echo $ipadress | egrep -e '172\.[0-9][0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?$'
# the test that doesnt work
if test -z `echo $ipadress | egrep -e '172\.[0-9][0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?$'` != ""
then
echo "match"
else
echo "dont match"
fi
When I run this, I get the message: "dont match"
But it matchs...
But when I run this:
ipadress=nothing
# for debugging:
echo $ipadress | egrep -e '172\.[0-9][0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?$'
# the test that doesnt work
if test -z `echo $ipadress | egrep -e '172\.[0-9][0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?$'` != ""
then
echo "match"
else
echo "dont match"
fi
I get the message: "match"
Thats not what I want! But What make I wrong?