Tente fazer isso usando awk :
top -b -n1 -c |
awk -vOFS=$'\t' '
$2 == "apache"{
virt+=$5; res+=$6; shr+=$7; cpu+=$9; mem+=$10; count++
}
END{
print "virt", "res", "shr", "cpu", "mem"
print virt, res, shr, cpu/count, mem/count
}
'