Sponsored Content
Operating Systems HP-UX pgrep doesn't perform full command line pattern matching Post 302433686 by Sapfeer on Wednesday 30th of June 2010 08:39:59 AM
Old 06-30-2010
pgrep doesn't perform full command line pattern matching

Hi! I need to get PID of some particular process and I wonder if I can use pgrep tool for this purpose. The problem is that pgrep doesn't perform pattern matching on the whole command line, even if I use -f key. Parsing output of ps command is not quite convenient... Also deamon, which PID I need to find, doesn't create any .pid files in /var/run. Any ideas and comments are greatly appreciated
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

bash pattern matching echo *[! '/' ] doesn't work

without using ls, just using echo so purely pattern matching I can say echo */ <-- lists directories but how would I match files? surely something like *!/ or * but neither work ? it seems like there isn't much that I can put in but surely i should be able to put any ascii... (1 Reply)
Discussion started by: james hanley
1 Replies

2. UNIX for Dummies Questions & Answers

exclude columns with a matching line pattern

Hi , I have 5 columns total and am wanting to search lines in columns 3-5 and basically grep -v patterns that match 'BBB_0123' 'BVG_0895' 'BSD_0987' Does anyone know how to do this? I tried combining grep -v with grep -e but, it didn't work. Thanks! (5 Replies)
Discussion started by: greptastic
5 Replies

3. Shell Programming and Scripting

comment/delete a particular pattern starting from second line of the matching pattern

Hi, I have file 1.txt with following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433 ** ** ** In file 2.txt I have the following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433... (4 Replies)
Discussion started by: imas
4 Replies

4. Shell Programming and Scripting

using command line arguments as columns for pattern matching using awk

Hi, I wish to use a column, as inputted by a user from command line, for pattern matching. awk file: { if($1 ~ /^8/) { print $0> "temp2.csv" } } something like this, but i want '$1' to be any column as selected by the user from command line. ... (1 Reply)
Discussion started by: invinclible0009
1 Replies

5. Shell Programming and Scripting

Extracting a string matching a pattern from a line

Hi All, I am pretty new to pattern matching and extraction using shell scripting. Could anyone please help me in extracting the word matching a pattern from a line in bash. Input Sample (can vary between any of the 3 samples below): 1) Adaptec SCSI RAID 5445 2) Adaptec SCSI 5445S RAID 3)... (8 Replies)
Discussion started by: jharish
8 Replies

6. Shell Programming and Scripting

matching pattern to end of line

I have the following code and want to get only the comments. Ideally I would like to replace the characters to the left of the first '!' in the line with blanks. real, dimension(:), allocatable :: ft ! stores a single trace real, dimension(:), allocatable :: tr ! stores a single... (8 Replies)
Discussion started by: kristinu
8 Replies

7. Shell Programming and Scripting

Matching pattern in two files and print the line

Hi, I want to match the pattern in file1 with file2 and print the value in file2 and paste in file1 file1: ISHO RT SR Major 96.46778 Drop Call Rate CS Critical 0.5072662 ISHO RT SR Major 97.754364... (3 Replies)
Discussion started by: khalil
3 Replies

8. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies

9. Shell Programming and Scripting

Removing spaces from line matching a pattern

Hi, I want to remove the spaces from all the lines matching a particular pattern from my file. For instance in file abc.txt I have following data. Header,This is the header 111,this is 1st record 222, this is 2nd record 333, this is 3rd record Footer,3 records found Footer,111222333 ... (5 Replies)
Discussion started by: decci_7
5 Replies

10. Shell Programming and Scripting

Fetching a line matching a pattern

Hi Gurus, I have a file as follows (Sample shown below but the list is very huge) SCHEDULE WS1#JS1 RUNCYCLE1 : WS1#JOB1 WS1#JOB2 FOLLOWS JOB1 END SCHEDULE WS2#JS1 RUNCYCLE2 : WS1#JOB3 WS1#JOB1 FOLLOWS JOB3 WS2#JOB1 (10 Replies)
Discussion started by: jayadanabalan
10 Replies
PGREP(1)							   User Commands							  PGREP(1)

NAME
pgrep, pkill - look up or signal processes based on name and other attributes SYNOPSIS
pgrep [options] pattern pkill [options] pattern DESCRIPTION
pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout. All the cri- teria have to match. For example, $ pgrep -u root sshd will only list the processes called sshd AND owned by root. On the other hand, $ pgrep -u root,daemon will list the processes owned by root OR daemon. pkill will send the specified signal (by default SIGTERM) to each process instead of listing them on stdout. OPTIONS
-signal --signal signal Defines the signal to send to each matched process. Either the numeric or the symbolic signal name can be used. (pkill only.) -c, --count Suppress normal output; instead print a count of matching processes. When count does not match anything, e.g. returns zero, the command will return non-zero value. (pgrep only.) -d, --delimeter delimiter Sets the string used to delimit each process ID in the output (by default a newline). (pgrep only.) -f, --full The pattern is normally only matched against the process name. When -f is set, the full command line is used. -g, --pgroup pgrp,... Only match processes in the process group IDs listed. Process group 0 is translated into pgrep's or pkill's own process group. -G, --group gid,... Only match processes whose real group ID is listed. Either the numerical or symbolical value may be used. -l, --list-name List the process name as well as the process ID. (pgrep only.) -n, --newest Select only the newest (most recently started) of the matching processes. -o, --oldest Select only the oldest (least recently started) of the matching processes. -P, --parent ppid,... Only match processes whose parent process ID is listed. -s, --session sid,... Only match processes whose process session ID is listed. Session ID 0 is translated into pgrep's or pkill's own session ID. -t, --terminal term,... Only match processes whose controlling terminal is listed. The terminal name should be specified without the "/dev/" prefix. -u, --euid euid,... Only match processes whose effective user ID is listed. Either the numerical or symbolical value may be used. -U, --uid uid,... Only match processes whose real user ID is listed. Either the numerical or symbolical value may be used. -v, --inverse Negates the matching. This option usually used in pgrep context. In pkill context the short option is disabled to avoid accidental usage of the option. -x, --exact Only match processes whose name (or command line if -f is specified) exactly match the pattern. -F, --pidfile file Read PID's from file. This option is perhaps more useful for pkill than pgrep. -L, --logpidfile Fail if pidfile (see -F) not locked. -V, --version Display version information and exit. -h, --help Display help and exit. OPERANDS
pattern Specifies an Extended Regular Expression for matching against the process names or command lines. EXAMPLES
Example 1: Find the process ID of the named daemon: $ pgrep -u root named Example 2: Make syslog reread its configuration file: $ pkill -HUP syslogd Example 3: Give detailed information on all xterm processes: $ ps -fp $(pgrep -d, -x xterm) Example 4: Make all netscape processes run nicer: $ renice +4 $(pgrep netscape) EXIT STATUS
0 One or more processes matched the criteria. 1 No processes matched. 2 Syntax error in the command line. 3 Fatal error: out of memory etc. NOTES
The process name used for matching is limited to the 15 characters present in the output of /proc/pid/stat. Use the -f option to match against the complete command line, /proc/pid/cmdline. The running pgrep or pkill process will never report itself as a match. BUGS
The options -n and -o and -v can not be combined. Let me know if you need to do this. Defunct processes are reported. SEE ALSO
ps(1), regex(7), signal(7), killall(1), skill(1), kill(1), kill(2) STANDARDS
pkill and pgrep were introduced in Sun's Solaris 7. This implementation is fully compatible. AUTHOR
Kjetil Torgrim Homme <kjetilho@ifi.uio.no> REPORTING BUGS
Please send bug reports to <procps@freelists.org> procps-ng September 2011 PGREP(1)
All times are GMT -4. The time now is 04:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy