Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the total physical memory in Bash to assign it to a variable?

Tags:

bash

How can I get the total physical memory in bytes of my Linux PC?

I need to assign it to a bash script variable.

like image 782
Neuquino Avatar asked Mar 14 '10 03:03

Neuquino


People also ask

How do I check my total physical memory?

Press Ctrl + Shift + Esc to launch Task Manager. Or, right-click the Taskbar and select Task Manager. Select the Performance tab to see current RAM usage displayed in the Memory box, and total RAM capacity listed under Physical Memory.

What is $@ in bash?

bash [filename] runs the commands saved in a file. $@ refers to all of a shell script's command-line arguments. $1 , $2 , etc., refer to the first command-line argument, the second command-line argument, etc. Place variables in quotes if the values might have spaces in them.


1 Answers

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

The returned number is in KB

like image 136
Neuquino Avatar answered Sep 28 '22 12:09

Neuquino