Skip to content

Instantly share code, notes, and snippets.

@SamRothCA
Created October 30, 2014 20:38
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save SamRothCA/b04f81897f48d0b1e36f to your computer and use it in GitHub Desktop.
Save SamRothCA/b04f81897f48d0b1e36f to your computer and use it in GitHub Desktop.
Memory Usage
ps xmo rss=,pmem=,comm= | while read rss pmem comm; ((n++<5)); do
size="$[rss/1024]";
short=$[4-${#size}];
size="(${size}M)";
i=0;
while ((i++ < short)); do size=" $size"; done;
pmem="${pmem%%.*}"
if (($pmem >= 20)); then color=$'\e[31m';
elif (($pmem >= 10)); then color=$'\e[33m';
else color=$'\e[32m ';
fi;
echo "$color$pmem% $size $(basename "$comm")"$'\e[0m'"";
done
@finkyseb
Copy link

Hi,
It should be

pmem="${pmem%%.*}";

Thanks for the script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment