I’m trying to find the total lines of running processes excepting the commands I’m using to create the listing.
Then to parse out the userID and the PID into a new list.
All within the same shell.
So far I have:
ps -ef | grep filename | wc -l
so here is a command for processes list:
ps -ef | tr -s ' ' | awk '{ if ($8=="/usr/sbin/apache2") print $1, $2 }'
We print only first two columns of each line (userId, PID) where column8 is equal to /usr/sbin/apache2 (process name)
and here is a command for processes count:
ps -ef | tr -s ' ' | awk '{ if ($8=="/usr/sbin/apache2") print $1, $2 }' | wc -l
grep filename
part for? It’s simply the output minus 4:ps
,grep
,wc
and lastly, yoursh
/bash
instance.