Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
48 lines (44 sloc) 1.18 KB
#!/bin/perl
#Usage: diffmany filename dir1 dir2
$argcnt=scalar(@ARGV);
print "$argcnt\n";
if ($argcnt !=3){
print "Number of arguments does not match\nUsage: diffmany filename dir1 dir2\n";
exit(1);
}
$srchfile=$ARGV[0];
$dir1=$ARGV[1];
$dir2=$ARGV[2];
if (! (-d $dir1 && -d $dir2) ){
print "Check whether the directories exist\n";
exit(1);
}
$outfile=$srchfile.DIFF;
open OUTFILE,">$outfile" or die "Could not open $outfile for write";
@content1=`find $dir1 -name $srchfile`;
#print "@content1";
@content2=`find $dir2 -name $srchfile`;
$cnt1=$#content1+1;
$cnt2=$#content2+1;
print "$cnt1\n";
print "$cnt2\n";
if ($cnt1==$cnt2){
foreach $i(0..$cnt1-1){
#print $i;
chomp($content1[$i]);
chomp($content2[$i]);
$arg1=$content1[$i];
$arg2=$content2[$i];
#print "$arg1 $arg2\n";
@diffcontent=`diff $arg1 $arg2`;
print OUTFILE "diff $arg1 $arg2\n";
$numdiff=scalar(@diffcontent);
if ($numdiff >0 ){
print OUTFILE "***********************************************\n";
print OUTFILE "diff $arg1 $arg2\n";
print OUTFILE "***********************************************\n";
print OUTFILE @diffcontent;
print OUTFILE "***********************************************\n";
}
}
}