Number of processes per each user in a table

Hello guys,

what i want to do is to print a table with two columns (user :: #procs) on the stdout.
The first column should show the users and the second one the number of processes the respective user runs.
I think I need something like the count() - function in sql, don't i?

Shell: Bash

Regards,
TipTop

I'm not quite sure. But you can try to play with 'ps' command. Something like this:

ps -A -a u | awk '{++users[$1]} END{for (a in users){print a " :: " users[a]}}'

but first read the man page for 'ps'. May be it lists other processes than you expect

If you are on linux, pgrep(1) is what you need.

$ pgrep -u user -c