Review your favorite Linux distribution.
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 08-13-2007, 12:49 PM   #1
Registered: Jan 2004
Posts: 108

Rep: Reputation: 15
creating a recursive DIFF command

I need to find the difference between 2 directories, basically I need to know what exists in the first directory that doesn't exist in the second directory. They are set up like the following:

/files/ ---(FIRST DIRECTORY)
file1 file2 file3 file4

/Files/ ---(SECOND)

The directory 'Files' has subdirectories which are supposed to contain all of the files in the directory 'files'. I need to find out if all of the files in /files/ are in /Files. I tried the command diff -r /files/ /Files/, but it was telling me that some of the files were only in 'files' when i know they existed in both.
Is there a better way to do this?
Old 08-13-2007, 12:58 PM   #2
Registered: Apr 2005
Location: Ohio
Distribution: Slackware && freeBSD
Posts: 676

Rep: Reputation: 30
rsync would be a good candidate for this task. It can create/update/delete files from source to destination if you so desire.

man rsync

There are great examples on here, just use the search feature and type in rsync.

Hope it helps some.

Edit: oops I'm sorry I think I misread your post, are you wanting an output only and not an updating of the differences between the directories?

Last edited by lord-fu; 08-13-2007 at 01:00 PM.
Old 08-13-2007, 02:33 PM   #3
Registered: Jan 2004
Posts: 108

Original Poster
Rep: Reputation: 15
I have written a little script that basically gives me to txt files. this.two. Now I know that there are 3 items in that are not in this.two. HOW do I use the DIFF command to show what they are, or where they are. I can't decipher the ouput when i use:
diff this.two

Last edited by OtisLinux; 08-13-2007 at 04:00 PM.
Old 08-13-2007, 08:34 PM   #4
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.7, Centos 5.10
Posts: 16,923

Rep: Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215
Depends what your problem is.
you might want to use the following flags:
diff -bB file1 file2
see man diff
Maybe try comm instead.


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
writing a recursive 'find' command nadroj Programming 5 03-06-2007 02:06 AM
Recursive diff ( File compare ) script sharathkv25 Programming 5 02-22-2007 09:39 AM
can 'ls' command be recursive? Hailey's_Comet Linux - Newbie 3 10-01-2006 01:29 AM
help on diff command anandss2004 Programming 2 11-01-2005 01:58 PM
the lovely recursive(-R) command mikeghet Linux - Newbie 3 12-23-2004 04:46 PM

All times are GMT -5. The time now is 05:41 PM.

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