- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: how to grep more than one word
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
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
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
тАО09-25-2008 10:57 PM
тАО09-25-2008 10:57 PM
How to grep the word starting with M and ?.I want to display the line starting with M and ?.I have tried the following command
egrep '(^M|^?)
But i am not getting the answer.
can any one help me out in this issue.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2008 11:45 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-26-2008 12:09 AM
тАО09-26-2008 12:09 AM
Re: how to grep more than one word
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-26-2008 03:59 AM
тАО09-26-2008 03:59 AM
Re: how to grep more than one word
oR
egrep "^M|^?"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-29-2008 03:23 AM
тАО09-29-2008 03:23 AM
Re: how to grep more than one word
To be sure anyway I would escape (\) the questionmark to make sure it matches.
Best regards
Fredrik Eriksson
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-29-2008 10:49 PM
тАО09-29-2008 10:49 PM
Re: how to grep more than one word
If grep on Linux is like grep on HP-UX, it takes regular expressions. And "?" is only special for Extended Regular Expressions, where it says the previous ERE is optional.
So you're probably correct in the egrep examples. For HP-UX you get this nice error:
egrep: ?, *, or + not preceded by valid regular expression
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2008 07:54 AM
тАО09-30-2008 07:54 AM
Re: how to grep more than one word
egrep "^M|^\?"
or
egrep "^[M?]"
will work.
egrep can have surprisingly different performance for different locales on linux.
Some implementations are quite a bit slower for the default utf8 locales. They will run faster after setting "export LANG=C". Other implementations are buggy and run horribly slow in utf8 locales.