Help Understanding While Loop

Jan Grant Jan.Grant at bristol.ac.uk
Sat Oct 15 11:25:47 PDT 2005


On Fri, 14 Oct 2005, Will Maier wrote:

> > count = $(( count + 1 ))
>              ^^^ 
> 
> You're missing something here ;)

Actually, you don't need the leading "$". With it, you'll get variable 
interpolation, which'll normally do the same thing. Once the expression 
has been interpolated, it's evaluated, using the values of any variables 
named in the expression.

That is,

count=1
count=$((count + 1))
will do what Drew intended. I think his problem is elsewhere (the while 
loop is a subshell).

-- 
jan grant, ILRT, University of Bristol. http://www.ilrt.bris.ac.uk/
Tel +44 (0)117 3317661   http://ioctl.org/jan/
"I think therefore I am." -- Ronnie Descartes


More information about the freebsd-questions mailing list