Mr. 0x50 Mr. 0x50 - 1 year ago 155
Linux Question

Linux/Terminal Grep Total Memory

I want only the number of my total RAM size.

When I try

grep MemTotal /proc/meminfo
, I get following:

MemTotal: 3943084 kB

But I want only the number, so i need to replace "MemTotal:" and "kB" with "" (nothing).
How to do this in terminal? (Maybe in one line?)

Answer Source

One approach would be

grep MemTotal /proc/meminfo | awk '{print $2;}'

Which "splits" the input at whitespace and displays only the 2nd word.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download