LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Finding duplicate directories (https://www.linuxquestions.org/questions/programming-9/finding-duplicate-directories-855075/)

NirvanaII 01-08-2011 05:42 PM

Finding duplicate directories
 
This simple task is proving harder then imagined. I have a multi-level directory that i'm trying to clean of duplicates, but I can't get 'find' to print what I need to see. To give an illustrative example, here is a dir:

Code:

stuart@stuart:~/testdir$ ls *
dir1:

level2:
dir1

So the output of find as i'd like it to work would show the two locations of dir1, which would be ./dir1 and ./level2/dir1. But no:

Code:

stuart@stuart:~/testdir$ ls -d */ | head -1 | find  . "`cat`" -type d
.
./level2
./level2/dir1
./dir1
dir1/

What am doing wrong?

rayfordj 01-08-2011 06:39 PM

does this do what you want?
Code:

find . -type d -name dir1 -print
:study:

NirvanaII 01-08-2011 06:58 PM

Yes - thankyou!

I actually know to use -name, (oops!), but screwed it up using the * wildcard. The -print option i'll look up in the man pages.


All times are GMT -5. The time now is 10:34 AM.