I am working on a script that will parse the /proc/meminfo file and return values. I have been able to pull the MemTotal and MemFree from that file but have stumbled on the next thing I want to do - calculate memory used via subtracting MemFree from MemTotal.
Would I do something like -
memfree=$(more /proc/meminfo | grep MemFree
memtotal=$(more /proc/meminfo| grep MemTotal
Let usedmem=$memtotal-$memfree
echo "Total Memory: $memtotal Free Memory: $memfree Memory in use: $usedmem
that? If not, what would be the best method to do this calculation?