drdot
drdot

Reputation: 3347

Diff between files in same directory structure in linux

I have two directories that contains the same directory structure, also directory names are same (possibly different number of files) and how can I find out the differences between all the file contents and files in Linux?

Here is an example

\dir1
  \subdir1
    \file1
  \subdir2
    \file2
    \file3


dir2
  \subdir1
    \file1
  \subdir2
    \file2
    \file3
    \file4

The content of file1 in dir1 and file1 in dir2 are different. The content of file2 in dir1 and file2 in dir2 are different. I can use

$diff dir1\subdir1\file1 dir2\subdir1\file1
$diff dir1\subdir1\file2 dir2\subdir1\file2

But I have to manually do the diff for each file. I would like to have an automatic way.

Upvotes: 1

Views: 129

Answers (1)

xlecoustillier
xlecoustillier

Reputation: 16351

If you want to list the files being different, try:

diff -rq dir1 dir2

If you want to list the difference inside each file, remove the q:

diff -r dir1 dir2

Upvotes: 2

Related Questions