Using shell scripting, how can I convert from one memory format to another and find the difference between them?

I want to compare current rate and previous memory rate (Where we need to compare decimal value with integer).

If it is positive it should display growth, If its negative it should display no growth, If it is 0 it should display constant.

For example

Name      current previous  
           rate   rate
Raju       6.7M  6.9M     
sita       52K   52K      
ravi       76K   76K       
seetha     52K   52K      
geetha     153M  56K      
ritta      13M   7.8G      

This is just a sample output--I want output like this!

Name      current previous  difference comment
           rate   rate
Raju       6.7M  6.9M     -0.2        No growth
sita       52K   52K       0          constant
ravi       76K   76K       0          constant
seetha     52K   52K       0          constant
geetha     153M  56K       97         growth
ritta      13M   7.8G      5.2        growth
  • 2
    for programming questions you might want to ask your question on Stack Overflow. however keep in mind, that none of the StackExchange sites are there to do your homework: what have you tried to solve the problem? and please don't add any "urgent" boilerplates. – umläute Mar 4 '15 at 10:04
  • Please comment where is mistake : 153M - 56K != 97 but == 152944000 Or you need not count multiplay suffixes ? – Costas Mar 4 '15 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.