How to Compare Differences Between Directories in Linux

linux

I have two directories – one from earlier backup and second from newest backup. How do i compare what changes were made to files in directory from newest backup on Linux? Also how do i display changes in for example text and php files – i'm thinking about something like revision history on wikipedia where you see old version on one side of the screen and newest version on other and changes are highlighted. How do i achieve something like that?

edit:
How do i also compare remote dir with local?

Best Answer

From diff man page:

If both from-file and to-file are directories, diff compares corresponding files in both directories, in alphabetical order; this comparison is not recursive unless the -r or --recursive option is given. diff never compares the actual contents of a directory as if it were a file. The file that is fully specified may not be standard input, because standard input is nameless and the notion of ‘‘file with the same name’’ does not apply.

So to compare directories: diff --brief -r dir1 dir2

To compare files side by side: diff --side-by-side file1 file2