Help on bash script?
Qiang.Xu at fujixerox.com
Fri Aug 12 02:52:31 GMT 2005
> On Fri, 12 Aug 2005, Xu Qiang wrote:
>> 1. The way of incrementing the variable NCOREFILES. Why does it use
>> the formula of "NCOREFILES=$[ $NCOREFILES + 1 ]", and not the direct
>> way of "NCOREFILES=$NCOREFILES+1"?
> If that was done, NCOREFILES would end up looking like:
> 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 "Learning the bash shell, 2nd ed" by O'Reilly at my hand. :(
And "man bash" didn't talk of it either. However, it mentioned for arithmetic evaluation, we can use
variable post-increment and post-decrement
variable pre-increment and pre-decrement
If it is correct, then I can also increment NCOREFILES by:
But I doubt it...
More information about the freebsd-questions