How can I get the sum of the following number? They are getting multiplied before getting added.
Input File (count.txt)
2*4
2*1
3*1
3*1
2*1
2*1
Command I am using:
( echo 0 ; sed 's/$/ +/' count.txt; echo p ) | dc.
The Sum I am getting is 343 which is not correct. I am expecting 20 as sum.
2*4
2*1
3*1
3*1
2*1
2*1
Sum: 20 (Multiplication and then sum for each line)
Any ideas?
Thanks, Raj