file1.txtComment concaténer les lignes correspondantes dans deux fichiers en Perl?
hello
tom
well
file2.txt
world
jerry
done
Comment fusionner file1.txt avec file2.txt; puis créez un nouveau fichier - file3.txt
hello world
tom jerry
well done
merci de lire et de répondre.
Rattaché au code complété basé sur la réponse.
#!/usr/bin/perl
use strict;
use warnings;
open(F1,"<","1.txt") or die "Cannot open file1:$!\n";
open(F2,"<","2.txt") or die "Cannot open file2:$!\n";
open (MYFILE, '>>3.txt');
while(<F1>){
chomp;
chomp(my $f2=<F2>);
print MYFILE $_ . $f2 ."\n";
}
-t-il être perl ou peut-il être linux? Vous pouvez faire $ coller fichier1.txt fichier2.txt – MJB
Dup: http://stackoverflow.com/questions/1636755/how-many-different-ways-are-there-to-concatenate-two-files-line-by- line-using-per/1636981 # 1636981 – FMc
Perl et WinXP utilisés. $ coller? Est-ce une commande de Linux? –