coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: expr shouldn't use spaces


From: Carl Edquist
Subject: Re: expr shouldn't use spaces
Date: Tue, 20 Dec 2022 13:52:05 -0600 (CST)

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

[Prev in Thread] Current Thread [Next in Thread]