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

2004-04-21 Thread Ion-Mihai Tetcu
Hi,


Could somebody explain me why in the second case I get an error (both
with test(1) and with sh's builtin) ?

[EMAIL PROTECTED] /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



-- 
IOnut
Unregistered ;) FreeBSD user

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


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

2004-04-21 Thread Joost Bekkers
On Wed, Apr 21, 2004 at 05:09:14PM +0300, Ion-Mihai Tetcu wrote:
 # if [ `cat ports_sup_log | wc -l` -nq 3 ]; then echo 'da'; fi

I think you mean -ne instead of -nq

-- 
greetz Joost
[EMAIL PROTECTED]
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


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

2004-04-21 Thread Ian D. Leroux
try -ne instead of -nq :-)

Ian

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) ?
 
 [EMAIL PROTECTED] /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
 
 
 
 -- 
 IOnut
 Unregistered ;) FreeBSD user
 
 ___
 [EMAIL PROTECTED] mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to [EMAIL PROTECTED]
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


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

2004-04-21 Thread Ion-Mihai Tetcu
On Wed, 21 Apr 2004 16:30:44 +0200
Joost Bekkers [EMAIL PROTECTED] wrote:

 On Wed, Apr 21, 2004 at 05:09:14PM +0300, Ion-Mihai Tetcu wrote:
  # if [ `cat ports_sup_log | wc -l` -nq 3 ]; then echo 'da'; fi
 
 I think you mean -ne instead of -nq

Duh, thanks. 

-- 
IOnut
Unregistered ;) FreeBSD user

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


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

2004-04-21 Thread Matthew Seaman
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) ?
 
 [EMAIL PROTECTED] /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


pgp0.pgp
Description: PGP signature


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

2004-04-21 Thread Dan Nelson
In the last episode (Apr 21), Ion-Mihai Tetcu said:
 Could somebody explain me why in the second case I get an error (both
 with test(1) and with sh's builtin) ?

 [EMAIL PROTECTED] /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

What do you expect -nq to do?  The equality tests are -eq (equal) and
-ne (not equal).

-- 
Dan Nelson
[EMAIL PROTECTED]
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


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

2004-04-21 Thread Mark Ovens
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) ?
[EMAIL PROTECTED] /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 'not equal' operator (I assume that is what you want) is -ne, not -nq

HTH

Regards,

Mark

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]