NetBSD-Users archive

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

Re: Arithmetic Expansion in shell.



On Fri, Aug 08, 2008 at 02:27:06PM +0100, Stephen Borrill wrote:
> On Fri, 8 Aug 2008, Glen Johnson wrote:
> >NetBSD-users,
> >I am trying to understand what I am doing wrong when using sh but not ksh.
> >In /bin/ksh I type:
> >echo $(( i=i+1 ))
> >I get the next value for i.
> >
> >In /bin/sh ,  I type the same thing:
> >echo $(( i=i+1 ))
> >I get this;  arith: syntax error: " i=i+1 "
> 
> Why do you have i= at the start? That's an invalid expression.

I guess you want to write
        i=$(($i + 1)); echo $i

HTH
        -is


Home | Main Index | Thread Index | Old Index