[Slackbuilds-users] Using something other than bash for rc scripts?

Charadon dev at iotib.net
Mon May 13 21:18:14 UTC 2024


Interesting... I was under the impression that bc was unable to do 
floating numbers. Probably a false memory or some article I read being 
wrong. ��

*From: *KB_SBo [mailto:sbo at linuxgalaxy.org]
*Sent: *Saturday, May 11, 2024 04:04 AM -04
*To: *slackbuilds-users at slackbuilds.org
*Subject: *[Slackbuilds-users] Using something other than bash for rc 
scripts?

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


_______________________________________________
SlackBuilds-users mailing list
SlackBuilds-users at slackbuilds.org
https://lists.slackbuilds.org/mailman/listinfo/slackbuilds-users
Archives -https://lists.slackbuilds.org/pipermail/slackbuilds-users/
FAQ -https://slackbuilds.org/faq/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.slackbuilds.org/pipermail/slackbuilds-users/attachments/20240513/e2d51688/attachment.htm>


More information about the SlackBuilds-users mailing list