|
Home > Archive > Unix Shell > December 2007 > Can we grep a list of all running PIDs in a file !!??
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Can we grep a list of all running PIDs in a file !!??
|
|
| marconi 2007-12-20, 7:35 am |
| Hi,
In the following part of a script, I am grepping the list of all
running PIDs in the File as in line 3 :-
$pid_count=`grep -c "^${pid_process}$" $CRI_PUSH_BIN_HOME/bin/
PushProcessId`
If I cannot grep this way, then how can I do so.
1 pid_process=`ps -ef -o pid,args | grep -v grep | grep -v $PROGNAME
| grep push | awk '{print $1}`
2 process=`ps -ef | grep -v grep | grep -v $PROGNAME | grep -c push`
3 pid_enregistre=`cat $CRI_PUSH_BIN_HOME/bin/PushProcessId`
4 no_pid_enregistre=`wc -l $CRI_PUSH_BIN_HOME/bin/PushProcessId | tr
' '`
5 found=1
6 for pid_val in "$pid_process"; do
7 $pid_count=`grep -c "^${pid_process}$" $CRI_PUSH_BIN_HOME/bin/
PushProcessId`
8 if [ $pid_count -eq 0 ]; then
9 found=0
10 pid_not_present="$pid_not_present $pid_val"
11 fi
12 done
Request you to pls lemme know .
Thanks a lot in advance.
| |
| John L 2007-12-20, 7:35 am |
|
"marconi" <kirankumar.techy@gmail.com> wrote in message news:fb8edb52-ce3f-41b3-a079-f7b1147acca3@e23g2000prf.googlegroups.com...
> Hi,
>
> In the following part of a script, I am grepping the list of all
> running PIDs in the File as in line 3 :-
> $pid_count=`grep -c "^${pid_process}$" $CRI_PUSH_BIN_HOME/bin/
> PushProcessId`
>
You can use grep -f filename, and you will probably want fgrep or grep -F
and -x as well; man grep for details.
However, the pgrep command probably already does what you want anyway;
man pgrep for details.
--
John.
|
|
|
|
|