Help on bash script?

Xu Qiang Qiang.Xu at
Fri Aug 12 02:52:31 GMT 2005

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=$[ $NCOREFILES + 1 ]", and not the direct
> 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 "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 
	 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: 

But I doubt it...

Xu Qiang

More information about the freebsd-questions mailing list