LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-13-2012, 05:03 AM   #1
krojther
LQ Newbie
 
Registered: Oct 2009
Posts: 20

Rep: Reputation: 0
Identify double occurrence of directory names


Dear All,
I am looking for a shell command that will identify all directories, each of which having the same name as one of its subdirectory.
For example:
Code:
/as/df/gh/sq12/sq12
or
Code:
/fgd/hgtre/gtsrew/hgt/mydirectory/mydirectory
Thanks
 
Old 09-13-2012, 05:29 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,503

Rep: Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434
find <root> -type d | grep -E '(/[^/]+)(/.+)?\1(\/|$)'
works for me, but probably not perfect
 
Old 09-13-2012, 06:32 AM   #3
krojther
LQ Newbie
 
Registered: Oct 2009
Posts: 20

Original Poster
Rep: Reputation: 0
Thanks,
and how can I filter from these results directories with certain patterns such as
dir1/dir2/dir3/mydir/mydir/ (the name starts with 'myd'
Thanks again
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] Listing file names side by side with directory names anon84 Linux - Newbie 3 04-03-2012 11:13 AM
[SOLVED] List files/directory names without directory contents? littlebigman Linux - Software 2 05-03-2011 05:42 AM
[SOLVED] How to changing same file names by their directory names? bayaraa_u Linux - General 3 04-09-2010 09:26 AM
What do the directory names stand for jken Linux - General 4 08-26-2004 08:26 AM
directory-names with spaces... Schmurff Linux - Newbie 2 03-07-2004 12:06 PM


All times are GMT -5. The time now is 12:55 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration