PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > linux.debian.user > Less and regular expressions
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
linux.debian.user debian-user@lists.debian.org.

Less and regular expressions

Réponse
 
LinkBack Outils de la discussion
Vieux 08/07/2008, 19h50   #1
Account for Debian group mail
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Less and regular expressions


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 me?

Thanks,

Ken


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 08/07/2008, 20h10   #2
Ron Johnson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Less and regular expressions

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/08/08 13:37, 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.


This might point you in the right direction:

$ cat /var/log/dmesg | perl -ne 'print if /usb/ && /low/'
usb 1-9: new low speed USB device using ohci_hcd and address 2
usb 1-9: new low speed USB device using ohci_hcd and address 3

- --
Ron Johnson, Jr.
Jefferson LA USA

"Kittens give Morbo gas. In lighter news, the city of New New
York is doomed."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkhzuSgACgkQS9HxQb37Xmc6zQCgoNdKBORhfB 3Q0uGjPzkChNQV
0GoAn3kFU2G3I/lq7v2G8zUbmwTjvWsQ
=BwxH
-----END PGP SIGNATURE-----


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 08/07/2008, 20h30   #3
Bob Cox
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Less and regular expressions

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 me?


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

grep greylist /var/log/syslog | grep 'aol\.com'

--
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
  Réponse avec citation
Vieux 08/07/2008, 20h40   #4
Bob McGowan
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: 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 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 s If you need a more complex search, I'll can take a
second (longer) look.

--
Bob McGowan

  Réponse avec citation
Vieux 08/07/2008, 21h20   #5
Stackpole, Chris
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: 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
  Réponse avec citation
Vieux 10/07/2008, 18h10   #6
Javier Barroso
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: 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 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
>
>


  Réponse avec citation
Vieux 10/07/2008, 23h00   #7
Josh Miller
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: 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 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
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 23h37.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,16456 seconds with 15 queries