Skip to content

Instantly share code, notes, and snippets.

@artemeff
Created Jul 21, 2015
Embed
What would you like to do?
function ram
set -l sum 0
set -l app $argv[1]
if [ -z $app ]
echo "First argument - pattern to grep from processes"
else
for i in (ps aux | grep -i "$app" | grep -v "grep" | awk '{print $6}')
set sum (math $sum + $i)
end
if [ $sum != "0" ]
echo "$app uses $sum MBs of RAM."
else
echo "There are no processes with pattern '$app' are running."
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment