How can I find out the total physical memory (RAM) of my linux box suitable to be parsed by a shell script?

前端 未结 13 1831
梦如初夏
梦如初夏 2020-12-07 09:52

I\'m typing a shell script to find out the total physical memory in some RHEL linux boxes.

First of all I want to stress that I\'m interested in the total ph

13条回答
  •  青春惊慌失措
    2020-12-07 10:17

    Total memory in Mb:

    x=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
    echo $((x/1024))
    

    or:

    x=$(awk '/MemTotal/ {print $2}' /proc/meminfo) ; echo $((x/1024))
    

提交回复
热议问题