Can we grep a list of all running PIDs in a file !!??

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can we grep a list of all running PIDs in a file !!??
# 1  
Old 12-20-2007
Can we grep a list of all running PIDs in a file !!??


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/

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/
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.
# 2  
Old 12-20-2007
Put 'CODE' tags round that to make it easier to read
What's in $CRI_PUSH_BIN_HOME/bin/PushProcessId ? Are you intentionally grepping through this file or do you want to use the contents to form your grep expression?
Line 3 looks different, do you mean line 7?

Please clarify where you believe the problem is.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep and ignore list from file

cat /tmp/i.txt '(ORA-28001|ORA-00100|ORA-28001|ORA-20026|ORA-20025|ORA-02291|ORA-01458|ORA-01017|ORA-1017|ORA-28000|ORA-06512|ORA-06512|Domestic Phone|ENCRYPTION)' grep -ia 'ORA-\{5\}:' Rep* |grep -iavE `cat /tmp/i.txt` grep: Unmatched ( or \( Please tell me why am i getting that (6 Replies)
Discussion started by: jhonnyrip
6 Replies

2. Shell Programming and Scripting

List creation - Grep a line in a file with a script name

Hi, I have a list file which has script names in them. Some scripts take lists as parameters which inturn have script names. This is basically for sequencing the job run. Eg: List1: test1.ksh test2.ksh test2.lst test3.ksh test3.lst test4.ksh test2.lst: test21.ksh test23.ksh... (7 Replies)
Discussion started by: member2014
7 Replies

3. Shell Programming and Scripting

Using perl to grep a list of patterns from an input file

I have been struggling to grep a file of NGrams (basically clusters of consonants or Consonant and Vowel) acting as a pattern file from an Input file which contains a long list of words, one word per line. The script would do two things: Firstly read a text pattern from a large file of such... (5 Replies)
Discussion started by: gimley
5 Replies

4. UNIX for Dummies Questions & Answers

Print file name when running grep from within find

Solaris 10 When running grep from within find command (don't know the technical term for 'running from within' ) , find command returns only the line which contains the pattern. Is there any way to get the file name printed as well ? $ pwd /opt/testdir/anotherDir $ $ $ cat findme.txt... (3 Replies)
Discussion started by: omega3
3 Replies

5. Homework & Coursework Questions

script to write PIDs to a file

script to write PIDs to a file Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: write a script that writes the PID of 2 different processes to a file every... (1 Reply)
Discussion started by: navlelo
1 Replies

6. Shell Programming and Scripting

Grep -v contents of a list file from another file.

Hello, I am trying to get output from FILE2 that excludes servers from list FILE1. I've tried a for loop with no success. Any ideas how to go about this? FILE1 contains: server1 server2 server3 server4 server5 FILE2 contains: server1:ERROR:user1: error message... (2 Replies)
Discussion started by: LinuxRacr
2 Replies

7. Programming

How to grep the specific string or user's list from the file

I have a file on UNIX system from where I want to grep the list of all users associated to the particular repository.If the user's list is in single line then I fetch all list but if it is in two separate lines it doesn't.I use the below command a=KESTREL-DEV;b=users;cat access_file|grep... (1 Reply)
Discussion started by: rohit22hamirpur
1 Replies

8. Shell Programming and Scripting

how to grep a file in list

hi all, for an example: In a file out.txt contains: /export/home/raghu/bin/debug_serverLog_apache_20090626_0625.txt How to grep or cut the value as "debug_serverLog_apache_20090626_0625.txt" or i want only the output as "debug_serverLog_apache_20090626_0625.txt" pls advice me (3 Replies)
Discussion started by: raghur77
3 Replies

9. Shell Programming and Scripting

find grep and list file name

find . -exec grep "something" {} \; this command only show the grep data but doesn't show the file name and path, how to show file path in this command? (4 Replies)
Discussion started by: bill.zheng
4 Replies

10. UNIX for Dummies Questions & Answers

How will you list only the empty lines in a file (using grep)

How will you list only the empty lines in a file (using grep) (1 Reply)
Discussion started by: JosephGerard
1 Replies
Login or Register to Ask a Question