Re: regular expression question
- From: Jim Gibson <jimsgibson@xxxxxxxxx>
- Date: Thu, 15 May 2008 12:12:49 -0700
In article
<1abd8794-b762-400e-9079-4876c603e5e2@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Orson <moleskyca1@xxxxxxxxx> wrote:
Sorry, this is probably silly question, but I cannot find right
answer.
I am trying to use grep -P (for perl regular expressions). I want to
match lines that do not contain the chars "sync".
Does your grep have the '-v' switch ('--invert-match'):
grep -v sync
I thought I could do:
grep -P "[^(sync)]" mytextfile
I understand [] matches any char in the brackets and (sync) groups
those chars together, so I would negate to mean should not match those
chars.
Parentheses group, but not inside brackets. "[^(sync)]" will match any
character other than the 6 listed. In Perl, you would negate the test:
$string !~ /sync/;
but that won't work as an option for grep. My grep doesn't have a '-P'
switch, so I can't tell how to use it. However, the -v switch seems to
do what you want.
--
Jim Gibson
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
http://www.usenet.com
.
- Follow-Ups:
- Re: regular expression question
- From: Orson
- Re: regular expression question
- References:
- regular expression question
- From: Orson
- regular expression question
- Prev by Date: FAQ 4.43 How do I compute the difference of two arrays? How do I compute the intersection of two arrays?
- Next by Date: Re: regular expression question
- Previous by thread: regular expression question
- Next by thread: Re: regular expression question
- Index(es):
Relevant Pages
|