From owner-freebsd-questions@FreeBSD.ORG Wed Apr 21 07:35:46 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EB98E16A4CE for ; Wed, 21 Apr 2004 07:35:46 -0700 (PDT) Received: from smtp.infracaninophile.co.uk (happy-idiot-talk.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 366C543D49 for ; Wed, 21 Apr 2004 07:35:46 -0700 (PDT) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost.infracaninophile.co.uk [IPv6:::1])i3LEZYIO044624 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 21 Apr 2004 15:35:34 +0100 (BST) (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost)id i3LEZY1R044623; Wed, 21 Apr 2004 15:35:34 +0100 (BST) (envelope-from matthew) Date: Wed, 21 Apr 2004 15:35:34 +0100 From: Matthew Seaman To: Ion-Mihai Tetcu Message-ID: <20040421143534.GC43999@happy-idiot-talk.infracaninophile.co.uk> Mail-Followup-To: Matthew Seaman , Ion-Mihai Tetcu , freebsd-questions@freebsd.org References: <20040421170914.5a5204a3@it.buh.cameradicommercio.ro> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="YD3LsXFS42OYHhNZ" Content-Disposition: inline In-Reply-To: <20040421170914.5a5204a3@it.buh.cameradicommercio.ro> User-Agent: Mutt/1.5.6i X-Virus-Scanned: clamd / ClamAV version devel-20040420, clamav-milter version 0.70k X-Spam-Status: No, hits=-4.8 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on happy-idiot-talk.infracaninophile.co.uk cc: freebsd-questions@freebsd.org Subject: Re: why test(1) works with -eq but not -nq ? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Apr 2004 14:35:47 -0000 --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--