Email address obfuscation in effect -- please
click here to turn it off.
[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
I moved this from the discussion list to the membership list...
Michael wrote:
> Can anyone think what the easiest method to search through a list of
> subdirectories for any files with the same names? Each subdirectory
> has thousands of files in it so effeciency is important. Thanks.
I'm not sure quite how your directories are arranged, but you should be
able to take the output of ls for both directories, awk, sort, uniq -c,
egrep, and get a list of files that are duplicated. For example, suppose
the directories are called dir1 and dir2, then this works on my system
(Solaris 2.6, so check the output at different stages in the pipeline to
be sure it works for you):
ls -1 dir1 dir2 | sort | uniq -c | egrep '^ 2' | cut -c 6-
It gives a list of all files that are in both directories. If you are
getting directory names in the output from ls, stick some awk code in
there... awk -F/ '{print $NF}' ...that will take out the dir names.
If you have many pairs of directories to check, you can write a script
with a double for loop to get all pairs.
Mike
--
To manage your subscription, go to http://mlug.missouri.edu/members/edit.php
Archives are available at http://mlug.missouri.edu/list-archives/