简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM