I would like to get the available memory reported as a percentage using a Linux command line.
I used the free command, but that is only giving me numbers, and there is no option for percentage.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using the
freecommand:Based on this output we grab the line with
Memand using awk pick specific fields for our computations.This will report the percentage of memory in use
This will report the percentage of memory that’s free
You could create an alias for this command or put this into a tiny shell script. The specific output could be tailored to your needs using formatting commands for the print statement along these lines: