Compare two folders which have many files inside contents

UnixShellDiff

Unix Problem Overview


Have two folders with approx. 150 java property files.

In a shell script, how to compare both folders to see if there is any new property file in either of them and what are the differences between the property files.

The output should be in a report format.

Unix Solutions


Solution 1 - Unix

To get summary of new/missing files, and which files differ:

diff -arq folder1 folder2

a treats all files as text, r recursively searched subdirectories, q reports 'briefly', only when files differ

Solution 2 - Unix

diff -r will do this, telling you both if any files have been added or deleted, and what's changed in the files that have been modified.

Solution 3 - Unix

I used

diff -rqyl folder1 folder2 --exclude=node_modules

in my nodejs apps.

Solution 4 - Unix

Could you use dircmp ?

Solution 5 - Unix

Diff command in Unix is used to find the differences between files(all types). Since directory is also a type of file, the differences between two directories can easily be figure out by using diff commands. For more option use man diff on your unix box.

 -b              Ignores trailing blanks  (spaces  and  tabs)
                 and   treats  other  strings  of  blanks  as
                 equivalent.

 -i              Ignores the case of  letters.  For  example,
                 `A' will compare equal to `a'.
 -t              Expands <TAB> characters  in  output  lines.
                 Normal or -c output adds character(s) to the
                 front of each line that may adversely affect
                 the indentation of the original source lines
                 and  make  the  output  lines  difficult  to
                 interpret.  This  option  will  preserve the
                 original source's indentation.

 -w              Ignores all blanks (<SPACE> and <TAB>  char-
                 acters)  and  treats  all  other  strings of
                 blanks   as   equivalent.    For    example,
                 `if ( a == b )'   will   compare   equal  to
                 `if(a==b)'.

and there are many more.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionvetri02View Question on Stackoverflow
Solution 1 - Unixreko_tView Answer on Stackoverflow
Solution 2 - UnixJohn KugelmanView Answer on Stackoverflow
Solution 3 - UnixMelvinView Answer on Stackoverflow
Solution 4 - UnixtoolkitView Answer on Stackoverflow
Solution 5 - UnixSachin ChourasiyaView Answer on Stackoverflow