![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here! |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
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 ....... |
| Forum Sponsor | ||
|
|
|
|||
|
You can't do floating-point arithmetic in the shell, it only supports integer calculations.
The parentheses in your script are syntax errors, but given the above, taking them out doesn't help much, of course. This looks suspiciously like something somebody else posted recently. Is this homework for a course? How to store values into variable in perl Last edited by Neo; 05-12-2008 at 07:14 AM. Reason: edited.... removed sarcasm. |
|||
| Google The UNIX and Linux Forums |