The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > Linux
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-07-2008
james1589 james1589 is offline
Registered User
 

Join Date: May 2008
Posts: 4
Arrow Please help me..

I am trying to get the output for memory information on Linux box.

Here is the cmd I ran on linux

free
output
-------
total used free
Mem: 122222 55500 66720


I need the out put like below..It is more helpful if any one can write this PERL..

Memory (MB)
total used(%) free(%)

12222 5550(47) 6672(53)


here is my sample.sh script that i used for this..

memory=$(free | awk '/Mem:/{print $2}')
usedmem=$(free | awk '/Mem:/{print $3}')
freemem=$(free | awk '/Mem:/{print $4}')
(freepct=(freemem*100)/memory))
((usedpct=100-freepct))
print "\n\n"
print " total used(%) free(%)\n"
printf "%5.0f %5.0f(%3.0f) %5.0f(%3.0f) ",$memory ,$usedmem ,$usedpct ,$freemem ,$freepct

I am getting some syntax error by running this. can you please help me to get the output(red colored) like the above either in PERL(preferred) or shell script..

I am waiting for you responses .......
Reply With Quote
Forum Sponsor