[BusyBox] ash and grep with busybox 1.00

Peter Kjellerstedt peter.kjellerstedt at axis.com
Mon Feb 21 16:07:01 UTC 2005


> -----Original Message-----
> From: busybox-bounces at mail.busybox.net 
> [mailto:busybox-bounces at mail.busybox.net] On Behalf Of 
> Florian Fainelli
> Sent: Monday, February 21, 2005 17:13
> To: busybox at mail.codepoet.org
> Subject: [BusyBox] ash and grep with busybox 1.00
> 
> Hi !
> 
> I would like grep to return me only one line, it is possible 
> to do that ? eg :
> 
>  ps aux | grep -c "/usr/sbin/telnetd"
> 1
>  ps aux | grep -c "/usr/sbin/telnetd"
> 2
> It's pretty unpredictable :) I could use sed to return me 
> only one line, but I does fit to my needs.

The reason you sometimes get 1 and sometimes 2, is probably
due to whether grep has triggered on itself in the list of
processes or not.

> Then, why does ash gives me an error when attempting to do that :
> 
> if [ `ps aux | grep -c telnet` >= "1" ]; then
> 	tel="on"
> else
> 	tel="off"
> fi
> 
> ash does not like >= operator ? Or am I wrong with the ash operators ?

Use -ge instead of >=.

> Thanks for your answers.

You should be able to use the following too:

if ps aux | grep -v grep | grep telnetd > /dev/null; then

//Peter



More information about the busybox mailing list