Mr. 0x50 Mr. 0x50 - 5 months ago 67
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?)


One approach would be

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

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