[X-Unix] finding duplicate files
Eric F Crist
ecrist at secure-computing.net
Wed Jun 20 11:12:45 PDT 2007
On Jun 20, 2007, at 12:27 PMJun 20, 2007, Robert Hoy wrote:
> Hi. Is there an efficient way to find files which are present in
> both gzipped and ungzipped form?
> They would be in the same directory, but I would like to search
> across all directories from one at high level. That is, I want to
> find all cases where "a" and "a.gz" are present in the same directory.
>
> Thanks,
> Rob
>
If you've got perl available, here's what I used:
#!/usr/bin/perl
foreach $file (`find . | grep -v .gz`) {
chomp($file = $file);
if (-e "$file.gz"){
print "$file\n";
}
}
If you don't want to put that in a file and run it, you can do the
following just as easily:
From a command prompt:
perl -e 'foreach $file ( `find . | grep -v .gz` ) { chomp ( $file =
$file ) ; if ( -e "$file.gz" ) { print "$file\n" ; } }'
This will search all directories from where it's run for file and if
file.gz exists, it will print the file name and directory. Note,
this doesn't search to see if file and file.gz exist in different
directories.
-----
Eric F Crist
Secure Computing Networks
More information about the X-Unix
mailing list