Skip to content

Instantly share code, notes, and snippets.

@mikecao
Created December 3, 2012 07:12
Show Gist options
  • Save mikecao/4193296 to your computer and use it in GitHub Desktop.
Save mikecao/4193296 to your computer and use it in GitHub Desktop.
Linux memory usage in human readable format
ps -eo size,pmem,pid,user,comm | sort -rn | head -10 | awk '{ hr[1024**2]="GB"; hr[1024]="MB"; for (x=1024**3; x>=1024; x/=1024) { if ($1>=x) { printf ("%6.2f %s ", $1/x, hr[x]); break } } } { printf ("%5s%% %-8s %-10s ", $2, $3, $4) } { for ( x=5 ; x<=NF ; x++ ) { printf ("%s ",$x) } print (" ") }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment