[Slackbuilds-users] Using something other than bash for rc scripts?
KB_SBo
sbo at linuxgalaxy.org
Sat May 11 08:04:37 UTC 2024
On 5/9/24 13:00, Charadon via SlackBuilds-users wrote:
re: bash
> lack of simple arithmetic
For integer arithmetic:
$ declare -i a=2+2
$ echo $a
4
$ let b=9+6 ; echo $b
15
$ echo $((2*5+1))
11
or maybe use
$ expr 2 + 3
5
and if you want to get really fancy, use the bc command for floating
point, functions, loops, and algebra:
$ echo "for(i=1; i<=10; i++) {scale=4;sqrt(i);}" | bc
1
1.4142
1.7320
2.0000
2.2360
2.4494
2.6457
2.8284
3.0000
3.1622
bash shell can indeed do a bit of arithmetic, and more.
-KB
More information about the SlackBuilds-users
mailing list