how to add 2 float values to each other?
i tried this and it doesnt work:
#!bin/bash
numone=1.234
numtwo=0.124
total=`expr $numone + $numtwo`
echo $total
thanks
how to add 2 float values to each other?
i tried this and it doesnt work:
#!bin/bash
numone=1.234
numtwo=0.124
total=`expr $numone + $numtwo`
echo $total
thanks
Try:
total=`echo $numone + $numtwo | bc`
thanks for that
How would I read in values from a text file and do the exact thing?
Text file contains 2 values: test.txt
1.51 -2.76
I want to read these values from test.txt and assign them to numone and numtwo:
# !bin/bash
numone=test.txt-value1
numtwo=test.txt-value2
total=`echo $numone + $numtwo | bc`
echo $total
#!/bin/ksh
read numone numtwo < test.txt
total=$(echo "scale=2; ${numone} + ${numtwo}" | bc)
echo "[${numone}] + [${numtwo}] = [${total}]"
For the future, pls create a new thread for the unrelated questions.
Thanks. Will do.