【问题标题】:Compare two folders which have many files inside contents比较两个文件夹,里面有很多文件
【发布时间】:2010-12-11 07:17:12
【问题描述】:

有两个文件夹,大约。 150 个 java 属性文件。

在shell脚本中,如何比较两个文件夹,看看其中是否有新的属性文件,以及属性文件之间有什么区别。

输出应该是报告格式。

【问题讨论】:

    标签: unix shell diff


    【解决方案1】:

    获取新/丢失文件的摘要,以及哪些文件不同:

    diff -arq folder1 folder2
    

    a 将所有文件视为文本,r 递归搜索子目录,q 仅在文件不同时报告“简要”

    【讨论】:

    • @reko_t 有没有办法通过Java运行它
    【解决方案2】:

    diff -r 将执行此操作,告诉您是否添加或删除了任何文件,以及已修改文件中的更改。

    【讨论】:

      【解决方案3】:

      我用过

      diff -rqyl folder1 folder2 --exclude=node_modules
      

      在我的 nodejs 应用程序中。

      【讨论】:

        【解决方案4】:

        你能用dircmp吗?

        【讨论】:

          【解决方案5】:

          Unix 中的 Diff 命令用于查找文件(所有类型)之间的差异。由于目录也是一种文件,因此可以使用 diff 命令轻松找出两个目录之间的差异。如需更多选项,请在您的 unix 机器上使用 ma​​n diff

           -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)'.
          

          还有更多。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2022-11-02
            • 1970-01-01
            • 2020-01-15
            • 2012-03-17
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多