Also, "$2" in a ps -ef command is the ProcessId, not the memory usage. The memory usage is not printed at all in ps -ef. You need to use the o option combined with "SZ" to get the memory size (but be aware that that is the "virtual" memory size, not necessarily the amount of memory currently in use by that process).

because you're awk statement doesn't produce anything. It sums, but does not print.

Edit: And I don't really know if it sums correctly. It's been ages since I've done anything with awk, so I'd have to look it up in order to be able to give you the correct syntax, and, truth be told, I don't really feel like it, right now. ;-)

Try this! ps -C bash -o pid=,size | awk '{SUM += $2} END {print SUM}' The problem is that your awk statement doesn't have a "print" command. You have to tell it what to print.

I also took some liberties in my example, and used some built in functions of PS rather than piping it through grep ;) The output of that ps statement is the pid and memory usage (in KB, so the final answer is also in KB)