awk top not getting the "k" result

Hi all,

I have the script :

 top -n 1 | awk '{ if (NR==4) print $5 }'

It will return me with one memory usage : for instance
3134720k

However, I need to be returned only the number : 3134720

Does anyone knows how to fix the script that return the number (without k)

thank you

top -n 1 | awk '{ if (NR==4) print int($5) }'
2 Likes
$ top -n 1 | awk 'NR==4{print substr($5,1,length($5)-1);exit}'
1045824

A sed solution (just because! :p)

top -bn1 | sed -n '/^Mem:/ s/^Mem:[^,]\+, \([[:digit:]]\+\).*$/\1/p'