On Thu, 25 Mar 2004 16:59:00 +0100
Manuel VACELET <[EMAIL PROTECTED]> wrote:

> Bonjour,
> 
> J'ai un petit probleme de shell, je souhaite extraire d'un fichier 
> toutes les lignes en double.
> details importants :
> * les lignes ne suivent pas forc�ment
> * je doit garder l'ordre du fichier (chronologique)
> 
> il s'agit d'un fichier de log (xferlog).
> 
> Si vous avez une idee ?
> 

Programme perl un peu "goret" qui doit marcher (j'ai mis stdin et stdout
ici mais il suffit de d�commenbter pour avoir le fichier entr�e et
sortie).

Fran�ois Boisson

#!/usr/bin/perl
# open(SORTIE , ">$ARGV[1]");
#print "Ouverture de $ARGV[1] en sortie\n";
# open(ENTREE , $ARGV[0]);
#print "Ouverture de $ARGV[0] en entree\n";
@liste=();
# while($ligne=<ENTREE>)
while($ligne=<STDIN>)
{
#    print "Etude de $ligne\n";
    $d=0;
    foreach $_ (@liste) {
        if ($ligne eq $_) {$d=1};
    }
    if ($d == 0) {
        @liste = (@liste,$ligne);
#       print SORTIE $ligne;
        print $ligne;
 };
}
#close(SORTIE);
#close(ENTREE);

Répondre à