Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 02-07-2005, 02:20 AM   #1
Registered: Dec 2004
Location: hong kong
Posts: 44

Rep: Reputation: 15
How can i find the difference for directory

Hi all,

We will use diff file1 file2 usually to find the diffreence for the files.
I would like to ask, if i want to find the difference for directory instead of file, any suggested command? sdiff?

Old 02-07-2005, 02:40 AM   #2
Senior Member
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973

Rep: Reputation: 46
did you try man diff?

try diff directory1 directory2

is that what you're looking for or something different?
Old 02-07-2005, 03:05 AM   #3
Registered: Dec 2004
Location: hong kong
Posts: 44

Original Poster
Rep: Reputation: 15
diff directory1 directory2 don't work as what i want is to compare the difference of directory instead of file content, for example. are there addition file or lack of some file?

Old 02-07-2005, 05:28 AM   #4
Senior Member
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
Try this script:

#! /bin/bash

# dirdiff - diff 2 directories


ls $DIR1 | sort >
       # list files in dir1, sort them alphabetically, and store in temp file
ls $DIR2 | sort >
      # same as dir 1, but for dir 2

echo "Differences are:"

#Clean up time:

*note: change this:
DIR1 = /path/to/directory/1
DIR2 = /path/to/directory/2
where /path/to/directory/1 is the path for the 1st dir, and same for the second.

Also - be sure to make it executable:
chmod 755 dirdiff
dirdiff was just an arbitrary name I chose - replace with a name you feel appropriate.

Also - make sure you're not in one of the directories when executing this, otherwise the diff will report the temp files as differences before they're deleted.

Last edited by scuzzman; 02-07-2005 at 05:37 AM.
Old 02-07-2005, 08:49 AM   #5
Registered: Apr 2004
Location: India
Distribution: Redhat,Fedora
Posts: 430

Rep: Reputation: 39
A simple
diff -rq Dir1 Dir2

will tell you which files are lacking or more in each dir.



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
reqd to find the difference between two files Prasun1 Linux - General 7 09-09-2005 05:16 PM
find size of directory naijaguy Linux - Newbie 3 03-04-2005 11:11 AM
exclude directory from find ebasi Linux - Software 8 07-17-2004 02:12 AM
Difference between directory and folder in windows? Squall General 7 02-03-2004 08:10 PM
How to find the directory of a binary (in C) DiscoStoo Programming 1 03-22-2002 03:29 PM

All times are GMT -5. The time now is 04:16 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