add text in the front
by spalisetty from LinuxQuestions.org on (#4ZSBX)
ubuntu@ip-172-31-92-85:~/suman$ cat floatbc.sh
#! /bin/bash
num1=20.5
num2=5
echo "$num1+$num2" | bc
echo "$num1-$num2" | bc
echo "$num1*$num2" | bc
echo "scale=2;$num1/$num2" | bc
echo "$num1%$num2" | bc
echo "scale=2;sqrt(4)" | bc -l
echo "scale=2;$num1^$num2" | bc -l
ubuntu@ip-172-31-92-85:~/suman$ ./floatbc.sh
25.5
15.5
102.5
4.10
.5
2.00
3620506.28
ubuntu@ip-172-31-92-85:~/suman$
I want to do something like this, how it can be achieved?
echo "addition:" "$num1+$num2" | bc
echo "subtraction:" "$num1-$num2" | bc
I just want to add respective text information for respective arithmetic operations.


#! /bin/bash
num1=20.5
num2=5
echo "$num1+$num2" | bc
echo "$num1-$num2" | bc
echo "$num1*$num2" | bc
echo "scale=2;$num1/$num2" | bc
echo "$num1%$num2" | bc
echo "scale=2;sqrt(4)" | bc -l
echo "scale=2;$num1^$num2" | bc -l
ubuntu@ip-172-31-92-85:~/suman$ ./floatbc.sh
25.5
15.5
102.5
4.10
.5
2.00
3620506.28
ubuntu@ip-172-31-92-85:~/suman$
I want to do something like this, how it can be achieved?
echo "addition:" "$num1+$num2" | bc
echo "subtraction:" "$num1-$num2" | bc
I just want to add respective text information for respective arithmetic operations.