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

Re: sed et travail sur un bloc contenant un motif



On Monday, 9 October 2017 22:11:31 CEST Alexandre Hoïde wrote:
>  sed, peut-être… perso je ne vois pas, mais peut-être. Par contre, gawk ?

Pas d'idée pour sed non plus.

L'exemple avec awk m'a fait penser à une option peu connue de perl qui permet 
de séparer un fichier en paragraphes ( -000) . Ce qui donne avec l'exemple de 
fichier ldif donné par Alexandre:

$ perl -n -000 -e 'print if /sAMAccountName: smith/;' fichier.ldif 
dn: CN=John Smith,OU=Users,DC=contoso,DC=com
proxyAddresses: SMTP:smith@contoso.com
proxyAddresses: smtp:John.Smith@contoso.com
proxyAddresses: smtp:jsmith@elsewhere.com
proxyAddresses: MS:ORG/ORGEXCH/JOHNSMITH
sAMAccountName: smith

dn: CN=John Smith,OU=Users,DC=contoso,DC=com
proxyAddresses: SMTP:smith@contoso.com
proxyAddresses: smtp:John.Smith@contoso.com
proxyAddresses: smtp:jsmith@elsewhere.com
proxyAddresses: MS:ORG/ORGEXCH/JOHNSMITH
sAMAccountName: smith

HTH

-- 
 https://github.com/dod38fr/   -o- http://search.cpan.org/~ddumont/
http://ddumont.wordpress.com/  -o-   irc: dod at irc.debian.org


Reply to: