Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] bash question



On Mon, 2003-02-17 at 21:06, Jean-Christian Imbeault wrote:
> I can't seem to find the proper bash syntax for this simple thing.
> 
> #!/bin/sh
> procs=`ps -aux | wc -l`
> if ($procs > 400) then
>    echo "You have more than 400 procs running"
> fi
> 
> If I run this I get:
> 
> # ./t.sh
> ./t.sh: 468: command not found
> 
> $procs is being interpreted as a command instead of an argument ... what 
> is the proper bash syntax to get a comparison done?
> 
> I've also tried:
> 
> if [ $proc -gt 400 ] then
>    echo "You have more than 400 procs running"
> fi
> 
> but that throws a:
> 
> ./t.sh: line 5: syntax error near unexpected token `fi'
> ./t.sh: line 5: `fi'
> 
> 
> Thanks,
> 
> Jc

Try "man test". In fact, test is symlinked to '[', meaning that the test
syntax can be used in shell as well with the '[', such as (in your
case):
if [ $proc -gt 400 ]
then
	echo etc...
fi

or:
if [ $proc -gt 400 ]; then
	echo etc...
fi

br.


-- 
GPG Key: 653514E5 (http://www.raoult.com/gpg)
--
Computers are like air-conditions. They don't properly work, if you open
Windows.

Attachment: signature.asc
Description: This is a digitally signed message part


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links