... condensed ...
>perl -wMstrict -le "my @filenames = qw( /data/node12/file-29-2.txt /data/node12/file-34-2.txt /data/node12/file-50-2.txt /data/node30/file-34-2.txt /data/node30/file-60-2.txt /data/node30/file-62-2.txt /data/node34/file-29-2.txt ); ;; my %seen; my @unique = grep { m{ (-\d\d-) }xms; !$seen{$1}++ } @filenames; print qq{'$_'} for @unique; " '/data/node12/file-29-2.txt' '/data/node12/file-34-2.txt' '/data/node12/file-50-2.txt' '/data/node30/file-60-2.txt' '/data/node30/file-62-2.txt'
If the file names are in a file with one name per line, this could even be a one-liner.
In reply to Re^2: Removing duplicate filenames in different directories from an array
by AnomalousMonk
in thread Removing duplicate filenames in different directories from an array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |