shell - Linux command for physical memory, getting the value only -
in linux cat /proc/meminfo | grep memtotal
gets memtotal: 12298824 kb
i want numbers here
so wrote cat /proc/meminfo | grep memtotal | cut -d':' -f2
gave me 12298824 kb
i want numbers here, can me?
note: cat /proc/meminfo | grep memtotal | cut -d':' -f2 | cut -d'k' -f1
gives me solution 12298824
, there better way? 1 liner?
use awk:
cat /proc/meminfo | grep memtotal | awk '{print $2}'
from @lars wirzenius's comment(no cat
, no grep
):
awk '/memtotal/ { print $2 }' /proc/meminfo
Comments
Post a Comment