Results 1 to 4 of 4
Hi everyone,
I am trying to write a small script that can output the RAM size.
I am doing this with the following command line:
system ("free -m | grep ...
- 06-25-2008 #1Linux User
- Join Date
- Jul 2007
- Location
- Greece
- Posts
- 277
RAM size
Hi everyone,

I am trying to write a small script that can output the RAM size.
I am doing this with the following command line:
system ("free -m | grep Mem");
The output I get is:
Mem: 999 916 83 0 106 265
Is there a way so that I can print out only the RAM size, which is the first number in the above row?
Thank you
- 06-25-2008 #2
- 06-25-2008 #3Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
Try using awk
There are lots of ways to do this however. How about...Code:free -m |grep Mem |awk '{print $2}'Though this again would require awk or similar to parse it.Code:grep MemTotal /proc/meminfo
EDIT :- Beat me to it Coopstah
- 06-25-2008 #4Linux User
- Join Date
- Jul 2007
- Location
- Greece
- Posts
- 277
Thank you very much guys


Reply With Quote