domlao
domlao

Reputation: 16029

Diff between two entire directories that contain source and output the result in a textfile

I have two directories that contain directories and source files. One directory contains the modified source code and the other one is unmodified source code. And I want to see what source code was modified and see the modified part of the code. And I also want to output the result to a single text file.

I know I have to use the diff tool but I'm not sure what options should I use. Do I need to create a script for this, or is there a one line command to do the task?

Upvotes: 20

Views: 19086

Answers (1)

Alex P.
Alex P.

Reputation: 770

You might want to do something like

diff -rw directory1 directory2 > diff.txt

where -r makes it recursive (so all sub-directories are scanned, too), -w is for ignoring all white-space (e.g., stray spaces or tabs somebody inserted), and > diff.txt redirects your output to the file diff.txt. More options can be found in the man page:

Upvotes: 43

Related Questions