Estou comparando 2 arquivos para duplicatas
cat file1
ac-list hostname permit tcp host 110.185.35.111 host 10.185.38.220 eq 1222
cat file2
ac-list hostname permit tcp host 10.185.35.111 host 10.185.38.220 eq 1222
Meu script é o seguinte:
#!/usr/bin/perl
open(SOURCE,"</home/user/file1");
open(DESTINATION,"</home/user/file2");
while(my $line = <SOURCE>)
{
while(my $line1 = <DESTINATION>)
{
chomp($line);
chomp($line1);
my @columns = split(' ',$line);
my @gitcols = split(' ',$line1);
my $fld1 = $columns[4];
my $fld2 = $columns[5];
my $fld3 = $columns[6];
my $fld4 = $columns[7];
my $fld5 = $columns[9];
my $gitfld1 = $gitcols[4];
my $gitfld2 = $gitcols[5];
my $gitfld3 = $gitcols[6];
my $gitfld4 = $gitcols[7];
my $gitfld5 = $gitcols[9];
if ($line == $line1 || awk '/$fld1/ && /host/ && /$fld2/ && /$fld3/ && /$fld4/ && /$fld5/' $line1)
{
print "\n All duplicate";
}
}
}
Estou recebendo o erro abaixo:
String found where operator expected at ./perltest line 25, near "awk '/$fld1/ && /host/ && /$fld2/ && /$fld3/ && /$fld4/ && /$fld5/'"
(Do you need to predeclare awk?)
Scalar found where operator expected at ./perltest line 25, near "'/$fld1/ && /host/ && /$fld2/ && /$fld3/ && /$fld4/ && /$fld5/' $line1"
(Missing operator before $line1?)
syntax error at ./perltest line 25, near "awk '/$fld1/ && /host/ && /$fld2/ && /$fld3/ && /$fld4/ && /$fld5/'"
syntax error at ./perltest line 30, near "}"
Execution of ./perltest aborted due to compilation errors.
No entanto, sem usar o comando awk, meu script está funcionando bem