سؤال

Possible Duplicate:
bash: $[<arithmetic-expression>] vs. $((<arithmetic-expression>))

The $(( expr )) construct can be used for integer math in bash, e.g.

echo $(( 2*2 + 1 )) # 5

$[ expr ] seems to do to do the same (but isn't documented):

echo $[ 2*2 + 1 ] # 5

Are these constructs equivalent in bash?

هل كانت مفيدة؟

المحلول

man bash says:

The format for arithmetic expansion is:

        $((expression))

The old format $[expression] is deprecated and will be removed in upcoming versions of bash.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top