开发者

How to print out size of physical memory in linux

开发者 https://www.devze.com 2023-04-12 07:47 出处:网络
If I use this grep MemTotal /proc/meminfo in linux ter开发者_开发知识库minal, I get MemTotal:2059908 kB.

If I use this grep MemTotal /proc/meminfo in linux ter开发者_开发知识库minal, I get MemTotal: 2059908 kB.

Does anybody know how to get numbers only? which will be 2059908?


One way is to filter the output with something like:

grep MemTotal /proc/meminfo | sed 's/[^0-9]//g'

This will remove all characters that aren't digits, as per the following transcript:

pax:~$ grep MemTotal /proc/meminfo
MemTotal:        4122788 kB

pax:~$ grep MemTotal /proc/meminfo | sed 's/[^0-9]//g'
4122788


Try adding this: |awk '{print $2}'


besides looking at /proc/meminfo, any of the following commands on LINUX will help: free, top

0

精彩评论

暂无评论...
验证码 换一张
取 消