[TriLUG] Learn something new every day.
Len Boyle
Len.Boyle at sas.com
Mon Feb 20 18:06:26 EST 2006
Never tried it but I also found a command called agrep in the "UNIX POWER TOOLS" book that says that it accepts "or" "and" and patterns.
len
-----Original Message-----
From: trilug-bounces at trilug.org [mailto:trilug-bounces at trilug.org] On Behalf Of Rick DeNatale
Sent: Monday, February 20, 2006 5:14 PM
To: Triangle Linux Users Group discussion list
Subject: Re: [TriLUG] Learn something new every day.
On 2/20/06, Jason Tower <jason at cerient.net> wrote:
> you can also combine multiple targets in one command. for example, i
> run the following in a screen session on all of my mail servers:
>
> tail -f /var/log/mail/info |grep -v -e pop3d -e imap
>
> the -v is a reverse grep, it returns everything -except- lines that
> match the target. i don't care about seeing each user that retreives
> their mail via pop or imap, i just want to see smtp messages.
>
> jason
But this isn't exactly what Brian was after which was to display lines which had both foo and bar, presumably in either order.
Multiple expressions -e foo -e bar will display lines which contain either foo or bar, as will the equivalent 'grep -F foo bar'
One way to do this is
grep -e 'foo.*bar' -e 'bar.*foo'
You should also be able to do
grep -e 'foo.*bar|bar.*foo'
but I can't seem to get that to work.
And by the way, this all reminds me of a new toy I recently discovered, but haven't really played with yet.
multitail lets you tail multiple files and/or command outputs (a al
watch) either in multiple ncurses windows, or combined, and apply different regex patterns to select and/or color the results.
--
Rick DeNatale
Visit the Project Mercury Wiki Site
http://www.mercuryspacecraft.com/
--
TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
TriLUG Organizational FAQ : http://trilug.org/faq/ TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
More information about the TriLUG
mailing list