-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdshbak
executable file
·70 lines (69 loc) · 1.64 KB
/
dshbak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/perl
#
# Copywrite Sept 2017
# Joe Bryant
# Apache 2.0
# All rights reserved
#
use File::Temp;
#use IO::Handle;
#STDIN->autoflush(1);
foreach $i (<>) {
($m,$d)=$i=~/^(.*?):(.*)/sig;
$machines{$m}++;
$line{$m}++;
$data{"$m"}.="$d";
}
@keys=sort keys %machines;
$count=@keys;
for (my $i=0;$i<$count;$i++) {
for (my $j=$i+1;$j<$count;$j++) {
$k1=$keys[$i];
$k2=$keys[$j];
$v1=$data{$k1};
$v2=$data{$k2};
if ($v1 eq $v2) {
$matchcnt[$i]++;
$matchcnt[$j]++;
$matchKey[$i].="$j~";
$matchKey[$j].="$i~";
}
}
}
$max=0;
$maxKey=0;
foreach $i (0..@matchcnt) {
if ($matchcnt[$i]>$max) {
$max=$matchcnt[$i];
$maxKey=$i;
}
}
push @k,$maxKey;
if ($matchKey[$maxKey] ne "") {
chop($matchKey[$maxKey]);
}
(@k1)=split('~',$matchKey[$maxKey]);
push @k,@k1;
print "*** These machines all match ***********************\n";
foreach $t (@k) {
print "* $keys[$t]\n";
$done{$keys[$t]}=1;
$done[$t]=1;
}
print "**********This is the data from the matches**********\n";
print "$data{$keys[@k[0]]}";
print "**********End of data from the matches***************\n";
($fh, $name) = mkstemp("tmpfileXXXXX");
print $fh $data{$keys[@k[0]]};
foreach $t (sort keys %data) {
if ($done{$t}!=1) {
($fh2, $name2) = mkstemp("tmpfileXXXXX");
print "\n********Deltas for $t*****************\n";
print $fh2 "$data{$t}";
print `diff $name $name2`;
`rm $name2`;
print "********End of deltas for $t**********\n";
}
}
`rm $name`;