1

I would like to divide two numbers which were extracted from a file using the below commands

temp1= grep PERM_ALLOCATED_SIZE /log/health_eg/DBsize.txt | cut -d':' -f2 | tr -d ' '
temp2= grep PERM_IN_USE_SIZE /log/health_eg/DBsize.txt | cut -d':' -f2 | tr -d ' '

and I'm able to print this

251658240
16239740

temp1 and temp2 respectively but I could not able to perform division for the above..

Sample output:

temp=temp2/temp1(0.064)
techraf
  • 64,883
  • 27
  • 193
  • 198

1 Answers1

0

A possible solution is using echo and bc -l:

echo "251658240/16239740" | bc -l

Output:

15.49644514013155383029

Using your example, you can do that:

temp=`echo $temp2/$temp1*0.64 | bc -l`
Marcel
  • 2,810
  • 2
  • 26
  • 46
  • Jacques Hi Marcel Actually I could not able to perform the division of the respective variables properly as It is taking some junk values and displaying irrelavant output. Can you suggest me something on this..Thanks in advance – Chakkula Prashanth Oct 12 '16 at 05:52
  • Hi. Did you try to use bc as I have shown? Could you paste your code? – Marcel Oct 12 '16 at 11:31