Compare two folders which has many files inside contents

后端 未结 5 1327
时光说笑
时光说笑 2020-12-07 09:58

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

相关标签:
5条回答
  • 2020-12-07 10:01

    I used

    diff -rqyl folder1 folder2 --exclude=node_modules
    

    in my nodejs apps.

    0 讨论(0)
  • 2020-12-07 10:02

    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.

    0 讨论(0)
  • 2020-12-07 10:17

    Could you use dircmp ?

    0 讨论(0)
  • 2020-12-07 10:19

    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

    0 讨论(0)
  • 2020-12-07 10:19

    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.

    0 讨论(0)
提交回复
热议问题