Date: Fri, 12 Aug 2005 10:54:49 +0800 From: Xu Qiang <Qiang.Xu@fujixerox.com> To: dpk <dpk@dpk.net>, Xu Qiang <Qiang.Xu@fujixerox.com> Cc: freebsd-questions@freebsd.org Subject: RE: Help on bash script? Message-ID: <20050812025115.CB2561D93C@imss.sgp.fujixerox.com>
next in thread | raw e-mail | index | archive | help
dpk wrote:
> On Fri, 12 Aug 2005, Xu Qiang wrote:
>> 1. The way of incrementing the variable NCOREFILES. Why does it use
>> the formula of "NCOREFILES=3D$[ $NCOREFILES + 1 ]", and not the direct
>> way of "NCOREFILES=3D$NCOREFILES+1"?
> =
> If that was done, NCOREFILES would end up looking like:
> =
> +1+1+1+1+1+1+1
> =
> as bash does not automatically differentiate between numeric and
> string variables. What the funky looking construct does is convince
> bash to treat it as a numeric/arithmetic expression.
Strangely, there is no mention of this assignment usage in the book "Learni=
ng the bash shell, 2nd ed" by O'Reilly at my hand. :(
And "man bash" didn't talk of it either. However, it mentioned for arithmet=
ic evaluation, we can use =
id++ id--
variable post-increment and post-decrement
++id --id
variable pre-increment and pre-decrement
If it is correct, then I can also increment NCOREFILES by: =
++NCOREFILES. =
But I doubt it...
Regards,
Xu Qiang
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050812025115.CB2561D93C>
