Created
November 7, 2016 20:08
-
-
Save ldante86/a9460cffa7333e74f1fec573c6cf3469 to your computer and use it in GitHub Desktop.
Get ram information from /proc/meminfo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash - | |
ram_info=/proc/meminfo | |
total_ram=$(bc <<< "scale=2; $(cat $ram_info | grep MemTotal | tr -d a-zA-Z:)/1024/1024") | |
free_ram=$(bc <<< "scale=2; $(cat $ram_info | grep MemFree | tr -d a-zA-Z:)/1024/1024") | |
used_ram=$(bc <<< "$total_ram-$free_ram") | |
echo "Total Ram: $total_ram G" | |
echo "Free Ram: $free_ram G" | |
echo "Used Ram: $used_ram G" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment