Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to concoct a way to grab two (nearly identical) directories and show me the difference between all files in the two directories.

Looking for two different things:

1- List all files (recursively) that are different between the two directories

2- Subtract all the files in /new-directory/ from /old-directory/ and output the results to a third directory or someplace where I can easily scan over the differences.

I'm looking for backdoors to a server by comparing a backed up (clean) directory to one with a suspected backdoor (inside a a previously existing file).

share|improve this question

1 Answer 1

up vote 1 down vote accepted

If your goal is to compare the files, you can use diff directly, for example in that way:

diff -r old-dir new-dir

With an option -q you can suppress the differences and get only a list which files differ, or if some files exist only in one of those directories.

$ diff -r old-dir new-dir
Only in old-dir: 2
diff -r old-dir/3 new-dir/3
0a1
> this line was inserted by an evil hacker... 

$ diff -rq old-dir new-dir
Only in old-dir: 2
Files old-dir/3 and new-dir/3 differ

There is also a graphical interface, called xxdiff which facilitate the screening of the differences; Screenshot taken from homepage:

enter image description here

share|improve this answer
    
Thanks! That's just what I was looking for. I didn't know if diff worked on a directory level. –  Orun Bhuiyan Mar 4 '13 at 20:50
    
@OrunBhuiyan: Glad I could help. Btw. I think its uncommon here to thank "personally", just upvote and/or accept the answer -- and welcome to Superuser :) –  mpy Mar 4 '13 at 20:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.