Help on bash script?
dpk
dpk at dpk.net
Fri Aug 12 03:04:39 GMT 2005
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))
More information about the freebsd-questions
mailing list