why test(1) works with -eq but not -nq ?

Matthew Seaman m.seaman at infracaninophile.co.uk
Wed Apr 21 07:35:47 PDT 2004


On Wed, Apr 21, 2004 at 05:09:14PM +0300, Ion-Mihai Tetcu wrote:
> Hi,
> 
> 
> Could somebody explain me why in the second case I get an error (both
> with test(1) and with sh's builtin) ?
> 
> itetcu at 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
> 
> # 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

-- 
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20040421/fa345ecb/attachment.bin


More information about the freebsd-questions mailing list