#!/bin/sh pids=`pidof $1` for i in $pids do memstat -w | egrep "[^0-9]$i[^k]" done | awk 'BEGIN{s=0}{s+=$1}END{print s"k"}'