"ps -ef" command and exact matching


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting "ps -ef" command and exact matching
# 1  
Old 11-04-2011
"ps -ef" command and exact matching

Hi Guys,
I am working in ksh88 and need the output of "ps -ef" command to give me the exact match of my pattern, for example:
Code:
$ ps -ef  'gen_sub'
     UID   PID  PPID NLWP  PGID   SID    STIME    TIME COMMAND
      op  9209  8249    1  9209  9209 14:52:57       00:00 /usr/bin/ksh /t1/bin/gen_sub
      op  6973  1278    1  6973  1278 15:07:12       00:00 gtail gen_sub_me
      op  3355  1278    1  3355  1278 15:06:43       00:00 gtail gen_sub

All I need that the above command would return only one line:
Code:
op  9209  8249    1  9209  9209 14:52:57       00:00 /usr/bin/ksh /t1/bin/gen_sub

All other lines in all possible combinations should be excluded.
Is there a way to do it? Thanks a lot for any advice... -A
# 2  
Old 11-04-2011
Code:
ps -ef | grep "/[u]sr/bin/ksh /t1/bin/gen_sub$"

# 3  
Old 11-04-2011
But your pattern is not univoque...
Have you tried
Code:
ps -ef  'bin/gen_sub'

# 4  
Old 11-04-2011
If you are on linux or solaris consider using pgrep for a better and exact match..."pgrep -lf gen_sub"
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

3. Shell Programming and Scripting

grep regex, match exact string which includes "/" anywhere on line.

I have a file that contains the 2 following lines (from /proc/mounts) /dev/sdc1 /mnt/backup2 xfs rw,relatime,attr2,noquota 0 0 /dev/sdb1 /mnt/backup xfs rw,relatime,attr2,noquota 0 0 I need to match the string in the second column exactly so that only one result is returned, e.g. > grep... (2 Replies)
Discussion started by: jelloir
2 Replies

4. UNIX for Dummies Questions & Answers

Unix "look" Command "File too large" Error Message

I am trying to find lines in a text file larger than 3 Gb that start with a given string. My command looks like this: $ look "string" "/home/patrick/filename.txt" However, this gives me the following message: "look: /home/patrick/filename.txt: File too large" So, I have two... (14 Replies)
Discussion started by: shishong
14 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

7. UNIX for Advanced & Expert Users

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

8. UNIX for Dummies Questions & Answers

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

9. UNIX for Advanced & Expert Users

The "PS" command was displaying*terminals named as "SYSCON"

Hi, When typing the command ps -fe.the system is showing a process called SYSCON:confused:.... I am not sure what process is that.I hava a script that kills all command staring with 'sys' but i don't want to kill syscon:( since i think it is some system process:confused: .Please help me to find... (1 Reply)
Discussion started by: kiranjose85
1 Replies

10. UNIX for Dummies Questions & Answers

How to find out the exact year in "Last modified time" using ls command

Hi, I understand that the ls command with "-l" option generates the "last modified time" of specific directory. However, some generated results displayed the "last modified time" with detail about the last modified year, for example: -rwxrwxrwx+ 1 smith dev 10876 May 16 2005 part2 ... (6 Replies)
Discussion started by: Dophlinne
6 Replies
Login or Register to Ask a Question