Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Jan 2013 13:29:49 -0500
From:      Rick Miller <vmiller@hostileadmin.com>
To:        Fbsd8 <fbsd8@a1poweruser.com>
Cc:        FreeBSD questions <questions@freebsd.org>
Subject:   Re: sh script ?
Message-ID:  <CAHzLAVGDZ4GKYMghqLHYOcgM8YkZhFP1Dp89t_10uK1xCD_5GQ@mail.gmail.com>
In-Reply-To: <5101786C.3070209@a1poweruser.com>
References:  <5101786C.3070209@a1poweruser.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jan 24, 2013 at 1:07 PM, Fbsd8 <fbsd8@a1poweruser.com> wrote:
> I get this message [: 10.0.10.21: bad number on this code
>
>    [ "${saved_ip}" -eq "${used_ip}" ] && echo "good match"
>
> Both variables have valid ip addresses in them.
> Why does it think the variable content is a number and not text?
> What am I doing wrong?

The -eq operator is used to compare integers.  When comparing strings,
use the == operator.


-- 
Take care
Rick Miller



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAHzLAVGDZ4GKYMghqLHYOcgM8YkZhFP1Dp89t_10uK1xCD_5GQ>