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?

1 Answer

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:

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like