Re: modification d'une partie d'un fichier texte...

Pàgina inicial

Reply to this message
Autor: Nicolas Tripon
Data:  
A: guilde
CC: guilde
Assumpte: Re: modification d'une partie d'un fichier texte...
Edgar Bonet :
>    #!/usr/bin/perl -pi

>
>    BEGIN {
>        # Delimit section of interest.
>        $mark_start = 'eth0';
>        $mark_end = '^$';

>
>        $in_preface = 1;
>        $in_postface = 0;
>    }

>
>    # Find the right section.
>    if ($in_postface or $in_preface and ! /$mark_start/) { next; }
>    $in_preface = 0;
>    if (/$mark_end/) { $in_postface = 1; next; }

>
>    # Do whatever processing is needed...
>    s/0/(zero)/g;    # dumb example


$ echo -e '/eth0/;/^$/s/0/(zero)/g\nwq' | ed /etc/network/interfaces

18 à 1 -- ou j'ai mal compris.
-Nicolas