How can i get the RAM Memory on system in terminal when i have 3 GB with an output like this:
3072
or
3145728
or
3221225472
Anyone knows this?
Just without MB in back of it, only the numbers. in MB, KB or B?
Thanks in Advance.
How can i get the RAM Memory on system in terminal when i have 3 GB with an output like this:
3072
or
3145728
or
3221225472
Anyone knows this?
Just without MB in back of it, only the numbers. in MB, KB or B?
Thanks in Advance.
grep 'MemTotal' /proc/meminfo
You have to cut off a few things there if you like.
thanks, i was looking for this, now i can use sed to cut out so i only have the numbers
You are welcome.
how to edit the output of this directly with sed or awk?
grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'
Can i set this as a integer variable? I now have this.
declare -i num=grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal:// ' -e 's/ kB//'
To get rid of the spaces in front:
grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal: *//' -e 's/ kB//'
To get this in an integer* num*:
declare -i num=$(grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal: *//' -e 's/ kB//')
declare -i num=$(free | awk '/Mem/{print $2}')
or (using a single sed command):
declare -i num=$(sed -n 's/MemTotal: *\(.*\) kB/\1/p' /proc/meminfo)