comparring 2 files: `sort $filesToCompre[0] >/dev/null 2>&1`;
`sort $filesToCompre[1] >/dev/null 2>&1`; `comm -23 $filesToCompre[0] $filesToCompre[1] > $Diff_File`; `comm -13 $filesToCompre[0] $filesToCompre[1*] * >>$Diff_File`; On Tue, Dec 30, 2014 at 1:22 PM, Alan Glait <agl...@gmail.com> wrote: > Thanks to all !!! > You are right Brandon .. Sorry about my post. > > I started searching how to compare 2 files like this: > use strict; > use warnings; > my $f1 = 'E:\upload\new\2.txt'; > my $f2 = 'E:\upload\new\a.txt'; > my $outfile = 'E:\upload\new\1.txt'; > my %results = (); > open FILE1, "$f1" or die "Could not open file: $! \n"; > while(my $line = <FILE1>){ > $results{$line}=1; > } > close(FILE1); > open FILE2, "$f2" or die "Could not open file: $! \n"; > while(my $line =<FILE2>) { > $results{$line}++; > } > close(FILE2); > open (OUTFILE, ">$outfile") or die "Cannot open $outfile for writing \n"; > foreach my $line (keys %results) { > print OUTFILE $line if $results{$line} == 1; > } > close OUTFILE; > > from > https://www.daniweb.com/software-development/perl/threads/79071/compare-two-text-file > > then I modify to print from which file is the line ... now ... how do I > test each value ... ?? I will try Andrew approach !! > > Thanks in advance > > 2014-12-30 5:40 GMT-03:00 Andrew Solomon <and...@geekuni.com>: > >> Hi Alan >> >> This is the module I'd use for it: >> >> https://metacpan.org/pod/Config::Tiny >> >> The simplest approach would be to: >> >> * read the destination config file (some_file.conf) into $Config_current >> * read the config in-tray (param.txt) into $Config_new >> * add the in-tray parameters to $Config_current >> >> foreach my $key (keys($Config_new->{_}) { >> $Config_current->{_}->{$key} = $Config_new->{$key}; >> } >> >> * write $Config_current back into some_file.conf >> >> Hope that helps! >> >> Andrew >> >> >> On Tue, Dec 30, 2014 at 3:47 AM, Alan Glait <agl...@gmail.com> wrote: >> > Hi ! >> > I have the Idea to make a perl script (better than in bash) to make some >> > configuration on linux. >> > I think to have some files like param.txt with some lines like: >> > param_one = ZZZ XX CCCC VV >> > param_two = ZZZZZZZZZ >> > param_three = X >> > >> > so need to check if param_one is in some_file.conf and if it is there >> test >> > the value .. if it is not .. add to some_file.conf ... I think it >> should be >> > easy ... right ?? >> > >> > Thanks for any help .. >> > >> > ;) >> >> >> >> -- >> Andrew Solomon >> >> Mentor@Geekuni http://geekuni.com/ >> http://www.linkedin.com/in/asolomon >> > > -- <http://il.linkedin.com/pub/ilan-shlossman/23/18/a97> *Ilan Shlossman+ 972-(0)54-5216764* <http://www.linkedin.com/in/ilanshlossman>