Sponsored Content
Full Discussion: Please help me..
Operating Systems Linux Please help me.. Post 302192819 by james1589 on Thursday 8th of May 2008 01:32:42 AM
Old 05-08-2008
CPU & Memory 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..Smilie

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 .......Smilie
 
LINUX-VERSION(1)					      General Commands Manual						  LINUX-VERSION(1)

NAME
linux-version - operate on Linux kernel version strings SYNOPSIS
linux-version compare VERSION1 OP VERSION2 linux-version sort [--reverse] [VERSION1 VERSION2 ...] linux-version list [--paths] DESCRIPTION
linux-version operates on Linux kernel version strings as reported by uname -r and used in file and directory names. These version strings do not follow the same rules as Debian package version strings and should not be compared as such or as arbitrary strings. compare VERSION1 OP VERSION2 Compare version strings, where OP is a binary operator. linux-version returns success (zero result) if the specified condition is satisfied, and failure (nonzero result) otherwise. The valid operators are: lt le eq ne ge gt sort [--reverse] [VERSION1 VERSION2 ...] Sort the given version strings and print them in order from lowest to highest. If the --reverse option is used, print them in order from highest to lowest. If no version strings are given as arguments, the version strings will instead be read from standard input, one per line. They may be suffixed by arbitrary text after a space, which will be included in the output. This means that, for example: linux-version list --paths | linux-version sort --reverse will list the installed versions and corresponding paths in order from highest to lowest version. list [--paths] List kernel versions installed in the customary location. If the --paths option, show the corresponding path for each version. AUTHOR
linux-version and this manual page were written by Ben Hutchings as part of the Debian linux-base package. 30 March 2011 LINUX-VERSION(1)
All times are GMT -4. The time now is 02:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy