Diff files present in two different directories

Sudar picture Sudar · Jan 7, 2010 · Viewed 232.8k times · Source

I have two directories with the same list of files. I need to compare all the files present in both the directories using the diff command. Is there a simple command line option to do it, or do I have to write a shell script to get the file listing and then iterate through them?

Answer

Laurent Etiemble picture Laurent Etiemble · Jan 7, 2010

You can use the diff command for that:

diff -bur folder1/ folder2/

This will output a recursive diff that ignore spaces, with a unified context:

  • b flag means ignoring whitespace
  • u flag means a unified context (3 lines before and after)
  • r flag means recursive