Grep: recherche emails
Résolu
tlep
Messages postés
597
Statut
Membre
-
jipicy Messages postés 40842 Date d'inscription Statut Modérateur Dernière intervention -
jipicy Messages postés 40842 Date d'inscription Statut Modérateur Dernière intervention -
Bonjour,
je patine (encore..) avec sed ou grep;
Je voudrais scruter le fichier de logs postfix; il est de ce type:
Aug 18 06:32:01 dev-apache postfix/local[26522]: D50031A983C: to=<[email protected]>, orig_to=<www-dat
a>, relay=local, delay=0.04, delays=0.03/0.01/0/0.01, dsn=2.0.0, status=sent (delivered to command: procmail -a "$EXTENSION")
Puis récupérer avec egrep l'email spécifié par to=<[email protected]>
et évidemment j'y arrive po
:-))
je patine (encore..) avec sed ou grep;
Je voudrais scruter le fichier de logs postfix; il est de ce type:
Aug 18 06:32:01 dev-apache postfix/local[26522]: D50031A983C: to=<[email protected]>, orig_to=<www-dat
a>, relay=local, delay=0.04, delays=0.03/0.01/0/0.01, dsn=2.0.0, status=sent (delivered to command: procmail -a "$EXTENSION")
Puis récupérer avec egrep l'email spécifié par to=<[email protected]>
et évidemment j'y arrive po
:-))
Configuration: Windows XP Firefox 2.0.0.6
A voir également:
- Grep: recherche emails
- Grep recursif - Forum Linux / Unix
- Style grep ✓ - Forum InDesign
- Commande grep - Forum Linux / Unix
- Grep plusieurs mots ✓ - Forum Linux / Unix
- Grep rm ✓ - Forum Linux / Unix
8 réponses
J'ai bien trouvé çà:
grep -Eo " to=<[^>]*" mes_logs
mais ca me donne :
to=<[email protected]
to=<[email protected]
et je voudrais exclure le " to=<" du coup pour n'avoir que l'email
grep -Eo " to=<[^>]*" mes_logs
mais ca me donne :
to=<[email protected]
to=<[email protected]
et je voudrais exclure le " to=<" du coup pour n'avoir que l'email
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Marche po: y me zappe les "@" et je me retrouve avec :
www-data
au lieu de "[email protected]"
Du coup g fait :
grep -Eo " to=<[^>]*"|sed 's/ to=<//g'
:-)
merci
www-data
au lieu de "[email protected]"
Du coup g fait :
grep -Eo " to=<[^>]*"|sed 's/ to=<//g'
:-)
merci
Il zappe pas les "@", c'est juste que l'expression matche aussi le second "to=" mais qui commence par "orig_to=" ;-\
Essaie comme ça alors :
Essaie comme ça alors :
egrep -o "\bto=.*>" fichier | sed 's/.*<\(.*\)>/\1/';-))
Ben pareil: il s'arrête aux '@' :
www-data
root
www-data
Mais bon pas grave ca marche comme j'ai fait.
www-data
root
www-data
Mais bon pas grave ca marche comme j'ai fait.
Bizarre ;-\
$ cat plop Aug 18 06:32:01 dev-apache postfix/local[26522] : D50031A983C: to=<[email protected]>, orig_to=<www-data>, relay=local, delay=0.04, delays=0.03/0.01/0/0.01, dsn=2.0.0, status=sent (delivered to command: procmail -a "$EXTENSION") $ egrep -o "\bto=.*>" plop | sed 's/.*<\(.*\)>/\1/' [email protected] $Comme tu le dis si l'autre syntaxe marche bien... après tout puisqu'on a le choix ;-))