Skip to content

Instantly share code, notes, and snippets.

@ldante86
Created November 7, 2016 20:08
Show Gist options
  • Save ldante86/a9460cffa7333e74f1fec573c6cf3469 to your computer and use it in GitHub Desktop.
Save ldante86/a9460cffa7333e74f1fec573c6cf3469 to your computer and use it in GitHub Desktop.
Get ram information from /proc/meminfo
#!/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