Visit Our UNIX and Linux User Community


ps-u


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers ps-u
# 1  
Old 09-18-2008
ps-u

I want to find out the number of processes returned by ps-u command..Need help.
# 2  
Old 09-18-2008
Code:
expr $(ps -u userlist | wc -l) - 1

# 3  
Old 09-18-2008
In most cases, this should do the trick (Linux Bash):

1. In Linux, you might want to get rid of the "-" in "ps -u" and just use "ps u" or you will get a warning message.

2. Count how many lines are presented before the actual list of processes produced by ps -u. Normally its 1, but could be 2 or more.

2. This example assumes 2 lines of text before the actual process data:
Code:
echo $[`ps u | wc -l`-2]


Last edited by Source2Exe; 09-18-2008 at 10:12 AM..
# 4  
Old 09-18-2008
Code:
ps -u user |awk 'END{ print NR - 1 }'

 

Previous Thread | Next Thread

Featured Tech Videos