Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 12-09-2012, 03:07 PM   #1
LQ Newbie
Registered: Dec 2012
Distribution: ubuntu
Posts: 1

Rep: Reputation: Disabled
Find duplicate files within directory tree

I have 2 directories full of e-books and I want to identify any duplicates between Directory A and Directory B.

They are stored like this

Directory A
- Sub-directory = Author name
- Sub-directory = book title
- Sub-directory = book title
- Sub-directory = Author name
Directory B
-Sub-directory = Author name
- Sub-directory = book title
- Sub-directory = book title
- Sub-directory = Author name

The aim is to consolidate the two sources down into one master list.

I'm at a pretty basic level of scripting and need to get this sorted out pretty quick otherwise I'd relish figuring it out myself. Any help will be amazing!

Old 12-09-2012, 04:18 PM   #2
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,147

Rep: Reputation: 887Reputation: 887Reputation: 887Reputation: 887Reputation: 887Reputation: 887Reputation: 887
i would pipe the results of a find command of directory-a into a for loop and check if it finds the same basename in directory-b.
Old 12-09-2012, 04:19 PM   #3
Registered: Jul 2009
Posts: 619

Rep: Reputation: 42
You can try a simple for loop:

for file in xyz/*
[[ -e "abc/$file" ]] && echo "abc/$file"


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
Find Duplicate Files alaios Linux - Software 4 01-30-2011 08:06 PM
Using diff to find new files in a directory tree madpear Programming 2 12-10-2009 10:27 AM
How to find the amd 64 dvd images in the directory tree yeehi Debian 4 11-27-2007 12:56 AM
Purge duplicate files in one directory smudge|lala Linux - General 8 03-30-2006 08:08 PM
duplicate directory tree for only certain file types curmudgeon42 Linux - Software 13 01-22-2005 02:38 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:52 AM.

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