Re: [SLE] multiple grep pattern
- From: Randall R Schulz <rschulz@xxxxxxxxx>
- Date: Sat, 3 Jun 2006 23:21:57 -0700
Ronald,
On Saturday 03 June 2006 21:57, Ronald Wiplinger wrote:
I want to find in a configuration file all lines starting with:
a. [
b. include
c. #include
This isn't entirely clear. Do you want to find lines that start with any
of those things? If so, this will do it:
% egrep '^(\[|#?include)' config.file
in the order as it is now!
I tried grep -e ^[|^include|^#include config.file but it did
not work.
The left square bracket is special both to the shell and to egrep. The
vertical bar is special to the shell and to egrep (but in a way
consistent with how you're using it).
When using non-trivial egrep, sed or find patterns, it's advisable to
simply enclose the entire pattern argument in single quote marks. Then
you need to escape those characters special to egrep patterns that you
want treated as literal characters (the square bracket, in this case).
How is the right syntax for it?
It looks from your attempt that you do in deed want to find any line
that begins with either a left square bracket, the word include or the
word include when preceded by a pound sign. In that case, the pattern I
gave above will work.
I suggest that you might want to be tolerant of white space around the
pound sign or before the include, in which case this would be a proper
formulation:
% egrep '^(\[| *#? *include)' config.file
bye
Ronald Wiplinger
Randall Schulz
--
Check the headers for your unsubscription address
For additional commands send e-mail to suse-linux-e-help@xxxxxxxx
Also check the archives at http://lists.suse.com
Please read the FAQs: suse-linux-e-faq@xxxxxxxx
- Follow-Ups:
- Re: [SLE] multiple grep pattern
- From: Randall R Schulz
- Re: [SLE] multiple grep pattern
- References:
- [SLE] multiple grep pattern
- From: Ronald Wiplinger
- [SLE] multiple grep pattern
- Prev by Date: Re: [SLE] Help! Kmail folder list does not show
- Next by Date: [SLE] VMware after an update
- Previous by thread: [SLE] multiple grep pattern
- Next by thread: Re: [SLE] multiple grep pattern
- Index(es):
Relevant Pages
|