On Mon, 19 Dec 2022, David Chmelik wrote:

 If the shell arithmetic is not sufficient, then I'd recommend bc(1).
Thanks! I was looking for that. I don't know whether bc or calc is better...

But, do try out the built-in shell arithmetic, too. (Eg, under "Arithmetic Expansion" and "ARITHMETIC EVALUATION" in the bash manpage.)

Basically anything in double-parens (( )) gets treated like integer math in C (you can even skip the $ prefix for variables), and $(( )) is the same but you can use the result as a string in your command line.

It doesn't handle floating-point (while bc(1) does), but if all you want is expr(1) math without needing spaces, the shell does just fine.

Carl

Reply via email to