Summarize memory consumption for linux processes

This script will summarize the memory consumption for a given pattern. It will filter all process args by this pattern and summarize the memory consumption.

#!/bin/bash

a=0
sum=0
for entry in `ps -eo rss,args | grep $1 | sed "s/\s.*//"` ; do
a=$(($a+1));
sum=$(($sum+$entry));
done
#echo $a;
echo "Found: $a processes - Memory Usage: $sum - $(($sum/1024))"