FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 07-08-2008, 07:04 PM
Bob McGowan
 
Default Less and regular expressions

Account for Debian group mail wrote:

Hello,

I'm doing a search of a syslog file using less - and having a brain fart.

I'm trying to make a regular search expression that will look for the word
"greylist" and the word "*.aol.com" in the same line of the syslog.

I just do not remember how to do this and looking around the Internet I'm
not finding what I need.

Can anyone help me?

Thanks,

Ken




That depends

Are you just looking for 'a' followed by 'b', or might you want to see
that and 'b' followed by 'a'?


Is the '*' in '*.aol.com' literal? And do you want to find only cases
where both words happen, or are you also interested in lines with one or
the other, alone?


The simple case ('a' followed by 'b', no specific regex characters to
take literally) would be to just say: greylis.*aol.com


Hope this helps If you need a more complex search, I'll can take a
second (longer) look.


--
Bob McGowan
 
Old 07-08-2008, 08:11 PM
"Stackpole, Chris"
 
Default Less and regular expressions

> I'm trying to make a regular search expression that will look for the
word
> "greylist" and the word "*.aol.com" in the same line of the syslog.

Do a Google search for "sed one liners"; I use that /ALL/ the time cause
I never remember all of the cool things sed can do. Anyway, specifically
there is a part that states:
# grep for AAA and BBB and CCC (in any order)
sed '/AAA/!d; /BBB/!d; /CCC/!d'
# grep for AAA and BBB and CCC (in that order)
sed '/AAA.*BBB.*CCC/!d'

So for you, I would suggest:
sed '/greylist/!d; /.aol.com/!d;' /path/to/syslog

Have fun!
~Stack~


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 07-10-2008, 04:59 PM
"Javier Barroso"
 
Default Less and regular expressions

On Tue, Jul 8, 2008 at 9:20 PM, Bob Cox <debian-user@lists.bobcox.com> wrote:

On Tue, Jul 08, 2008 at 11:37:11 -0700, Account for Debian group mail (debian@pcez.com) wrote:



>

> Hello,

>

> I'm doing a search of a syslog file using less - and having a brain fart.

>

> I'm trying to make a regular search _expression_ that will look for the word

> "greylist" and the word "*.aol.com" in the same line of the syslog.

>

> I just do not remember how to do this and looking around the Internet I'm

> not finding what I need.

>

> Can anyone help me?



Admittedly this does not answer your question (using 'less'), but this

should work:



grep greylist /var/log/syslog | grep 'aol.com'If you want context lines (-3 before and +4 later in the example you could use A and B switch):

grep -A4 -B3 "greylist.*.aol.com" /var/log/syslog | less

*



--

Bob Cox. *Stoke Gifford, near Bristol, UK.

Registered user #445000 with the Linux Counter - http://counter.li.org/





--

To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org

with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 07-10-2008, 09:43 PM
"Josh Miller"
 
Default Less and regular expressions

> On Tue, Jul 8, 2008 at 9:20 PM, Bob Cox <debian-user@lists.bobcox.com>
> wrote:
>
>> On Tue, Jul 08, 2008 at 11:37:11 -0700, Account for Debian group mail (
>> debian@pcez.com) wrote:
>>
>> >
>> > Hello,
>> >
>> > I'm doing a search of a syslog file using less - and having a brain
>> fart.
>> >
>> > I'm trying to make a regular search expression that will look for the
>> word
>> > "greylist" and the word "*.aol.com" in the same line of the syslog.
>> >
>> > I just do not remember how to do this and looking around the Internet
>> I'm
>> > not finding what I need.
>> >
>> > Can anyone help me?


less +/'greylist.**.aol.com' <file>


--
Josh Miller, RHCE


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 

Thread Tools




All times are GMT. The time now is 06:40 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org