In Linux cat /proc/meminfo | grep MemTotal gets back MemTotal: 12298824 kB
I want only the numbers here
so i wrote cat /proc/meminfo | grep MemTotal | cut -d':' -f2 which gave me 12298824 kB
I only want the numbers here, can anyone help me?
Note: cat /proc/meminfo | grep MemTotal | cut -d':' -f2 | cut -d'k' -f1 gives me the solution 12298824, but is there a better way? one liner?
Use awk:
From @Lars Wirzenius’s comment(No
catand Nogrep):