Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Aug 2005 20:04:29 -0700 (PDT)
From:      dpk <dpk@dpk.net>
To:        Xu Qiang <Qiang.Xu@fujixerox.com>
Cc:        Giorgos Keramidas <keramida@ceid.upatras.gr>, freebsd-questions@freebsd.org
Subject:   RE: Help on bash script?
Message-ID:  <20050811200106.S5643@shared10.hosting.flyingcroc.net>
In-Reply-To: <20050812025925.942541D9A4@imss.sgp.fujixerox.com>
References:  <20050812025925.942541D9A4@imss.sgp.fujixerox.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 12 Aug 2005, Xu Qiang wrote:

> This is my test script:
>
> ---------------------
> #!/bin/bash
>
> var=0
> var=$[3]
>
> vari=0
> ++vari
>
> echo $var
> echo $vari
> ---------------------
>
> The result is:
> ./test.sh: ++vari: command not found
> 3
> 0
>
> So the manual of bash is incorrect?
>
> Regards,
> Xu Qiang

It will work with either 'let' or within an 'arithmetic expansion':

$[++var]
let ++var

By the way, there is another syntax, from the man page, that seems to
operate identically:

$((++var)) and $((var+1))



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050811200106.S5643>