Bash integer expansion
How many ways bash can deal with integer expansion ? I only know 4 methods, I think there are more:
1. use let:
$ a=5
$ let b=a*6
-
use expr:
$ a=5 $ b=`expr $a \* 6`
-
use $[ ... ]:
$ a=5 $ b=$[ $a * 6 ]
-
use $(()):
$ a=5 $ b=$(( a * 6 ))
- in method 1 and 4, the variable a is "NAKED".
Written by Chao YANG
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Related Tags
#shell
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#