Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Linux Math with Decimal Places?

Here's the code to do my math:

csv=`cat *.csv | wc -l`; hashes=`expr $csv / 2`; expr $hashes / 882349483 \* 100

However, since $hashes / 882349483 is equal to about 0.0023432, I'm just getting a response of 0. I'm guessing that expr can't display decimals in their answers?

What would I need to change to use bc or something similar?

Note: My first use of expr is okay, that'll always be a whole number. It's the second instance that returns a decimal.

Edit: I'm aware that stuff like bc can be used, which is why I mentioned it in the original question. What I don't know is how to implement it in my example...

Here's what I did to get it working:

csv=`cat *.csv | wc -l`; hashes=`expr $csv / 2`; echo print $hashes/882349483*100 | perl

Comments