Re: Basic Grep Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 13/03/07, Marc Schwartz <marc_schwartz@xxxxxxxxxxx> wrote:
Dotan,

Keep in mind that he is EXCLUDING lines that have those two values, so
in this case, the use of '|' (OR) gets the desired result. A line cannot
have either value, which is the same as saying that a line cannot have
both values.

I manned the -v option after posting. Sorry. I'm still a bit close to
the X axis on the learning curve.

If he wanted lines that INCLUDED both values, then the approach would
require the piped double grep approach,

That's what I thought he was doing. Until I manned -v.

One approach, for example, might be to use a Perl based Regex, with
Lookahead. This one will return lines in .Xresources that have BOTH
'xterm' AND 'white' in them:


$ grep -P "(?=.*xterm)(?=.*white)" .Xresources
xterm*background: white

My god, that's scary.

or return lines that have BOTH 'default' AND 'ground':


$ grep -P "(?=.*default)(?=.*ground)" .Xresources
Emacs.default.attributeBackground:      white
Emacs.default.attributeForeground:      black
XEmacs*EmacsFrame.default.attributeForeground: black
XEmacs*EmacsFrame.default.attributeBackground: white

Agh! Stop!

In this way, we can combine multiple regex's in a single grep call.

I'll just continue double grepping, until I fully explore Beagle. Thanks.

Dotan Cohen

http://technology-sleuth.com/long_answer/how_can_i_be_safe_online.html
http://what-is-what.com/what_is/microsoft_windows.html


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux