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).


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
> 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

  • Thanks! That's just what I was looking for. I didn't know if diff worked on a directory level. – Orun 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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