Is there way of counting the number of processes being run by a user in the unix/linux/os x terminal?
For instance, top -u taha
lists my processes. I want to be able to count these.
This will show all of the users with their counts (I believe this would be close enough for you. :)
ps -u "$(echo $(w -h | cut -d ' ' -f1 | sort -u))" o user= | sort | uniq -c | sort -rn
You can use ps
to output it and count the number using wc
, as:
ps -u user | sed 1d | wc -l
You can also dump top
output and grep it, something like:
top -u user -n1 | grep user | wc -l
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With