LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-08-2011, 05:42 PM   #1
NirvanaII
Member
 
Registered: Jun 2005
Posts: 139

Rep: Reputation: 18
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?
 
Old 01-08-2011, 06:39 PM   #2
rayfordj
Member
 
Registered: Feb 2008
Location: Texas
Distribution: Fedora, RHEL, CentOS
Posts: 488

Rep: Reputation: 78
does this do what you want?
Code:
find . -type d -name dir1 -print
 
Old 01-08-2011, 06:58 PM   #3
NirvanaII
Member
 
Registered: Jun 2005
Posts: 139

Original Poster
Rep: Reputation: 18
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.

Last edited by NirvanaII; 01-08-2011 at 07:15 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding duplicate lines in a file MikeyCarter Linux - Software 3 10-05-2008 05:28 PM
duplicate entry finding cmontr Linux - General 1 05-21-2008 11:04 PM
finding duplicate songs tommytomthms5 Linux - Software 1 05-21-2008 09:36 AM
Finding duplicate files SlowCoder Linux - General 6 10-12-2007 08:25 AM
Script to find duplicate files within one or more directories peter88 Linux - General 6 12-10-2006 05:17 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration