Human readable system memory reading crom CLI?

view story

http://unix.stackexchange.com – On OS X, I get a nice human readable system memory reading like so: printf -v system_memory \ "$(system_profiler SPHardwareDataType \ | awk -F ': ' '/^ +Memory: /{print $2}')" echo "$system_memory" prints out the friendly: 4 GB Although this on Linux is correct: lshw -class memory it outputs: size: 4096MiB I need to painfully parse it and try to make it into a string as nice as the one above. Am I using the wrong command? (HowTos)