- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: grep for multiple patterns
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
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
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
тАО04-20-2005 04:55 AM
тАО04-20-2005 04:55 AM
Quick question on the use of 'grep'
I have a need to do multiple greps of processes from the command line. Each pattern will be different but I have to check for the occurance of any of these patterns.
I have tried
ps -ef | grep a b c d e
Responds that "grep can't open b c d e"
Would I need to do;
ps -ef | grep a | grep b | grep c | grep d
Or is there a better way?
Thanks!
Solved! Go to Solution.
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-20-2005 04:59 AM
тАО04-20-2005 04:59 AM
Re: grep for multiple patterns
ps -ef | grep 'a b c d e'
ps -ef | egrep "a|b|c|d|e"
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-20-2005 05:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-20-2005 05:00 AM
тАО04-20-2005 05:00 AM
Re: grep for multiple patterns
I think extended regular expressions (ERE) are what you're looking for:
ps -ef |grep -e "a" -e "b" -e "c" -e "d" -e "e"
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-20-2005 05:03 AM
тАО04-20-2005 05:03 AM
Re: grep for multiple patterns
greps pat1 OR pat2 OR pat3 OR pat5
# grep pat1 file | grep pat2 | grep pat3
greps pat1 AND pat2 AND pat3
# grep -e pat1 -e pat2 file | grep pat3
greps (pat1 OR pat2) AND pat3
# perl -ne'/pat1/||/pat2/||/pat3/and print'
pat1 OR pat2 OR pat3
# perl -ne'(/pat1/||/pat2/)&&/pat3/and print'
(pat1 OR pat2) AND pat3
etc etc ...
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-20-2005 05:06 AM
тАО04-20-2005 05:06 AM