Skip to content

Instantly share code, notes, and snippets.

@o0-o
Last active May 7, 2019 02:31
Show Gist options
  • Save o0-o/e87a0564c95d9fce11f70c81c73c1bf3 to your computer and use it in GitHub Desktop.
Save o0-o/e87a0564c95d9fce11f70c81c73c1bf3 to your computer and use it in GitHub Desktop.
[Memory] Prints amount of memory in bytes #Shell
# mem.sh
( # linux
grep "MemTotal" /proc/meminfo |
awk '{ printf "%d\n", $2 * 1000 }' ||
# bsd
sysctl -n hw.realmem 2>/dev/null ||
# macos
# TODO: this number is returning ~68GB on a system with 64GB installed
sysctl -n hw.memsize 2>/dev/null ||
) 2>/dev/null ||
exit 1 #failure
exit 0 #success
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment