Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # return free memory in MB
- #method 1: short but slow
- ##########################
- #top="/usr/bin/top"
- #grep="/usr/bin/grep"
- #cut="/usr/bin/cut"
- #top -l 1 | grep ^PhysMem |cut -c62-66
- #method 2:
- ##########################
- vm_stat="/usr/bin/vm_stat"
- awk="/usr/bin/awk"
- free="$(( $(vm_stat | awk '/free/ {gsub(/\./, "", $3); print $3}') * 4096 / 1048576)) MiB free RAM"
- echo="/bin/echo"
- echo $free
- exit
Add Comment
Please, Sign In to add comment