bash arithmatic

Arithmetic in bash is done with $ and double parentheses:

echo "$(($num1+$num2))"
Or $ and square brackets:

echo "$[$num1+$num2]"
You can assign from that (sans echo). There is also expr:

echo `expr "$num1" + "$num2"`

  http://unix.stackexchange.com/a/93030

posted @ 2014-07-09 10:21  Daniel King  阅读(173)  评论(0编辑  收藏  举报