Re: regular expression question



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
.



Relevant Pages

  • Re: regular expression question
    ... match lines that do not contain the chars "sync". ... you would negate the test: ... but that won't work as an option for grep. ... the word "sync". ...
    (comp.lang.perl.misc)
  • Re: [SLE] grep
    ... > Wonder if someone could give me the way to grep for an word within all ... > files on my system like the filename would be XXXX.XX ... will do a case insensitive file match for all files with 4 chars ...
    (SuSE)
  • Re: findstr doesnt always find
    ... properly handled search strings longer than 115+ chars. ... so I'll see how its grep holds up. ...
    (microsoft.public.win2000.cmdprompt.admin)
  • regular expression question
    ... Sorry, this is probably silly question, but I cannot find right ... I am trying to use grep -P (for perl regular expressions). ... match lines that do not contain the chars "sync". ...
    (comp.lang.perl.misc)
  • Re: interface speed support
    ... If I have a gigabit ethernet device connected to a ... sysctl -A | grep phy | grep desc ... If it is connected to a 100baseTX switch, ... For controlling and querying the media type that you're actually using, ...
    (freebsd-stable)