- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: use of grep
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2008 01:07 AM
01-16-2008 01:07 AM
use of grep
ps -ef |grep sendmail
root 3875 1 0 2007 ? 00:03:40 sendmail: accepting connections
smmsp 3875 1 0 2007 ? 00:00:01 sendmail: Queue runner@01:00:00
for /var/spool/clientmqueue
root 5875 5874 0 15:00 ? 00:00:00 /usr/sbin/sendmail -FCronDaemon
-i -odi -oem -oi -t
root 28078 23007 0 17:02 pts/17 00:00:00 grep sendmail
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2008 01:14 AM
01-16-2008 01:14 AM
Re: use of grep
ps -ef | grep sendmail | grep -v grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2008 01:14 AM
01-16-2008 01:14 AM
Re: use of grep
use the -v parameter:
ps -ef |grep sendmail | grep -v grep
check man grep for -v
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2008 01:15 AM
01-16-2008 01:15 AM
Re: use of grep
Mark Syder (like the drink but spelt different)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2008 01:19 AM
01-16-2008 01:19 AM
Re: use of grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2008 01:36 AM
01-16-2008 01:36 AM
Re: use of grep
it works , but I found that same problem if my command is as below , while the directory have sendmail process id in it , can advise how to fix it ? thx.
ll directory |grep sendmail |grep -v grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2008 01:38 AM
01-16-2008 01:38 AM
Re: use of grep
root 1311 1 0 09:42:42 ? 0:01 sendmail: accepting connections
#man ps
Regards,
Asif Sharif
Asif Sharif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2008 01:55 AM
01-16-2008 01:55 AM
Re: use of grep
ll directory |grep sendmail |grep -v grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2008 02:31 AM
01-16-2008 02:31 AM
Re: use of grep
ps -ef | grep [s]endmail
The regexp "[s]endmail" matches the word "sendmail" only, but when it's expressed in this way, the line of the grep process won't match the regexp and so won't get included.
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2008 03:43 AM
01-16-2008 03:43 AM
Re: use of grep
For example:
ps -ef | grep sendmai[l]
hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2008 05:01 AM
01-16-2008 05:01 AM
Re: use of grep
Use the below command to find correct output from the process table.
example : top process
#UNIX95=1 ps -f -C top
UID PID PPID C STIME TTY TIME CMD
root 335 323 0 06:53:11 pts/1 00:00:00 top
If you want to grep only then ,
# ps -aef |grep top|grep -v grep
root 335 323 0 06:53:11 pts/1 0:00 top
#
Thanks,
Aneesh
ps -aef |grep top|grep -v
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2008 10:09 PM
01-16-2008 10:09 PM
Re: use of grep
what my problem is when I use the command ll , the ll itself is a process , it will write the process id to the directory (the directory contains all process id ), what I want is use "ll directory |grep -i pid |grep -v grep" , and it do not show the process which generated from ll , can advise how to do it ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2008 12:03 AM
01-17-2008 12:03 AM
Re: use of grep
1. will not show pids
2. will not include the ll command.
Can you please clarify what you are trying to do?
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2008 12:06 AM
01-17-2008 12:06 AM
Re: use of grep
"it" who? How does ll(1) write the PID to the directory?
>I want is use "ll directory | grep -i pid | grep -v grep", and it do not show the process which generated from ll, can advise how to do it?
How did we get from using the -C option for ps(1) to ll(1)?
You had a question about:
ll directory |grep sendmail |grep -v grep
>the directory contains all process id)
Are you saying you created a filename with the PID and the process name and arguments?
We need to see the results of:
ll directory | grep sendmail
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2008 12:31 AM
01-17-2008 12:31 AM
Re: use of grep
If an OS has a /proc filesystem, it usually lists processes by process ID numbers, not by process names. I'm not aware of any OS that would create a directory listing of process names.
As this question is on a HP-UX administration forum, we obviously tend to assume that you're asking about HP-UX unless you explicitly say otherwise.
If you know your question is specific to Linux or Tru64 (Digital Unix), please use the forum sections that are dedicated to those OSs, to avoid this kind of confusion.
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2008 12:47 AM
01-17-2008 12:47 AM
Re: use of grep
better way to fix your problem is to use the UNIX95 as already suggested.
A possible solution is that you write teh pid of teh process into a file and after use it to look for your process using ps -p.
Just .02$
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2008 12:19 PM
01-17-2008 12:19 PM
Re: use of grep
ps -f -p 123
And you get exactly that process ID.
If you want to find all processes owned by a particular user, use ps -u like this:
ps -f -u billh
You never want to search for a process by name using grep -- use the -C option in ps. For the -C option, a temporary variable must be used to enable the -C option, like this:
UNIX95=1 ps -f -C sh
Compare the output of the above command with this:
ps -e -f | grep sh
This illustrates the very unstable nature of using grep with ps. grep does not know what you are looking for -- it matches anything on the line.
Once you read the man page for ps, you'll never use ps and grep together again.
Bill Hassell, sysadmin