Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Apr 2004 15:35:34 +0100
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        Ion-Mihai Tetcu <itetcu@apropo.ro>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: why test(1) works with -eq but not -nq ?
Message-ID:  <20040421143534.GC43999@happy-idiot-talk.infracaninophile.co.uk>
In-Reply-To: <20040421170914.5a5204a3@it.buh.cameradicommercio.ro>
References:  <20040421170914.5a5204a3@it.buh.cameradicommercio.ro>

next in thread | previous in thread | raw e-mail | index | archive | help

--YD3LsXFS42OYHhNZ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Apr 21, 2004 at 05:09:14PM +0300, Ion-Mihai Tetcu wrote:
> Hi,
>=20
>=20
> Could somebody explain me why in the second case I get an error (both
> with test(1) and with sh's builtin) ?
>=20
> itetcu@it> /var/log/ports [16:51:38] 0
>  # sh
> # cat ports_sup_log | wc -l
>        3
> # if [ "`cat ports_sup_log | wc -l`" -eq "3" ]; then echo 'da'; fi
> da
> # if [ "`cat ports_sup_log | wc -l`" -nq "3" ]; then echo 'da'; fi
> [:        3: unexpected operator
>=20
> # if (/bin/test "`cat ports_sup_log | wc -l`" -eq "3") ; then echo 'da'; =
fi
> da
> # if (/bin/test "`cat ports_sup_log | wc -l`" -nq "3") ; then echo 'da'; =
fi
> test:        3: unexpected operator

The test for numeric inequality is '-ne':

    % [ 3 -ne 5 ] && echo yes
    yes
    % /bin/test 3 -ne 5 && echo yes
    yes

	Cheers,

	Matthew

--=20
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

--YD3LsXFS42OYHhNZ
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD8DBQFAhoa2dtESqEQa7a0RAgiPAJ0a3Ux6sj4bnKdDDdvP73PQmXBOBgCbBtYJ
iUCs6m3WgqGf0Q/3YQ+UCQw=
=i4gN
-----END PGP SIGNATURE-----

--YD3LsXFS42OYHhNZ--



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