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
#! /usr/bin/perl
use warnings;
use strict;
use Getopt::Long;
my ($filterPassword, $filterIp, $file, $file2);
my $help = 0;
# z.B. program.pl -p password -i 127.0.0.1 -file datei.txt
# oder: program.pl -h
GetOptions(
"password=s" => \$filterPassword,
"ip=s" => \$filterIp,
"file=s" => \$file,
"file2=s" => \$file2,
"help" => \$help,
);
if ($help) {
# &PrintHelp....
exit 1;
} # if
# vielleicht hier noch ueberpruefen, ob $filterPassword und $filterIp gesetzt sind....
unless (open (LOG, "<", $file)) {
die "Error: couldn't open '$file': $!\n";
} # unless
my %filteredLines;
while (<LOG>) {
chomp($_);
my ($ip, $pass) = split(/ /, $_);
if ($pass eq $filterPassword and $ip eq $filterIp) {
$filteredLines{$_} = 1;
} # if
} # while
close (LOG);
open(FILE2,"<$file2") or die $!;
while(<FILE2>){
chomp $_;
my ($ip, $pass) = split(/ /, $_);
if ($pass eq $filterPassword and $ip eq $filterIp) {
print $_,"\n" if($filteredLines{$_});
} # if
}
close FILE2;
Das funktioniert mit den beiden .txt-Dateien, die Du gepostet hast...