Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 05-06-2002, 09:58 AM   #1
Registered: Jan 2002
Location: UK
Distribution: Ubuntu
Posts: 45

Rep: Reputation: 15
How Compare FS/dirs - can't use 'diff'?

I want to compare the files present in two filesystems or directory trees, and to list which files are present in one tree but not in the other. I don't think 'diff -r' can be used to directly compare the directories because one of the trees is the root fs on which the other fs (a different partition containing a cpio copy of the root fs) must be mounted.

The only way I can think of is to do: 'cd /; find . > file1' with the second filesystem unmounted, then to mount the second filesystem and do: 'cd 2nd-fs; find . > file2', then to compare file1 to file2.
But the big problem here is that 'diff' lists over 700 lines which are different, although most of them are not missing files! Most of them are just files listed in a different order.
If the first files in both filesystems were different, then every line of the 'find' output from one fs will be different from the same line number in the other 'find' output file, and 'diff' will list all lines as different, even though nearly all the files will be the same. So I want to list only the files listed in one file that are not listed ANYWHERE in the second file.

I'm sure it can be done with 'sed', but just the mention of 'sed' gives me a headache - surely there's an easier way? - please!
Old 05-06-2002, 10:27 PM   #2
Registered: Apr 2001
Location: chicago, IL
Distribution: debian, redhat
Posts: 280

Rep: Reputation: 30
i use gtkdiff - which is a very nice version of diff. - nice color coding etc... else i would do as you are i.e. ls > file
Old 05-07-2002, 07:51 AM   #3
Senior Member
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
How about running the output of find through sort.
Ex: find . | sort > file1


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Diff compare 2 files DavidTempler Linux - Newbie 2 11-01-2004 10:00 AM
Dual Boot diff Hard Disk diff OS on Suse 9.1 wilhem Linux - Newbie 1 08-13-2004 06:06 PM
How to see just dirs with ls? d1s4st3r Linux - Newbie 3 06-04-2004 10:45 AM
Using diff to compare file with common lines, but at different line numbers jimieee Linux - Newbie 3 05-10-2004 07:26 AM
hidden dirs? mighty Linux - General 3 11-03-2001 03:38 PM > Forums > Linux Forums > Linux - General

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