zoukankan      html  css  js  c++  java
  • linuxdiff命令

    git diff适用于git管理的文件。而diff命令则没有限制。但一般系统文件都在版本控制中,所以git diff用的比较多。

    推荐diff -u

    一。参数
    1.diff格式参数
    -u 输出统一格式,-c是传统格式。diff有"传统"和"统一"两种格式,一般使用"统一"格式,即-u . 比较而言,统一格式生成的文件大,但包含了更多的信息,有利于阅读与定位
    注意到-c 与-u这二种格式不能同时使用。你只能使用其中一种格式化输出内容
    diff -u -c   /home/gaoyibo/php-site/php-site/src/Search/web.xml /home/gaoyibo/search/workspace/searchServer/WebContent/WEB-INF/web.xml > web.patch
diff: conflicting output style options
diff: Try `diff --help' for more information.
     
    了解-u的输出格式:同一块内容,里面用+,-区分文件的修改。
--- /home/gaoyibo/php-site/php-site/src/Search/web.xml    2011-11-08 15:38:07.000000000 +0800
    +++ /home/gaoyibo/search/workspace/searchServer/WebContent/WEB-INF/web.xml    2011-11-07 11:22:45.000000000 +0800
    @@ -25,8 +25,9 @@
         <servlet-name>InitServlet</servlet-name>
         <servlet-class>com.daodao.servlet.InitServlet</servlet-class>
         <init-param>
    +      <!-- change path -->
           <param-name>propspath</param-name>
    -      <param-value>/home/search/config/</param-value>
    +      <param-value>/home/gaoyibo/search/resource/</param-value>
         </init-param>
         <init-param>
           <param-name>propsname</param-name>
    2.diff目录用到参数
    如果比较二个目录,使用-r,表示Recursively compare any subdirectories found.      -x 用来排除目录中的某个文件
     
     
    
**3.其它参数
    -a  Treat all files as text.
    -b  Ignore changes in the amount of white space.
    -N   如果某个文件只在一个目录中出现,则假定在另一个目录中为空文件.

    查看diff -acb生成的patch文件:

    示例1:注意下页的示例只为说明-c,推荐使用-u。

    不会针对同行做修改。只有增减。注意,这种情况下,---文件的变化都是在***里使用“-”来标志。---部分没有内容。这与!时的情况不同。

    diff -r -a -c -b -x Makefile.temp /home/gaoyibo/search/workspace/searchServer/src/com/daodao/application/search/Indexer.java /home/gaoyibo/php-site/php-site/src/Search/src/com/daodao/application/search/Indexer.java
    *** /home/gaoyibo/search/workspace/searchServer/src/com/daodao/application/search/Indexer.java    2011-10-27 14:21:12.000000000 +0800
    --- /home/gaoyibo/php-site/php-site/src/Search/src/com/daodao/application/search/Indexer.java    2011-11-08 15:38:07.000000000 +0800
    ***************
    *** 1,7 ****
      package com.daodao.application.search;
     
      import java.io.BufferedOutputStream;
    -
      import java.io.BufferedReader;
      import java.io.File;
      import java.io.FileInputStream;
    --- 1,6 ----
    ***************
    *** 62,68 ****
      //    private static PinYinSearchTree m_cPinYinSearchForLocation = new PinYinSearchTree();
         
     
    -     //
          public static LinkedBlockingQueue<Document> m_lDocQueue = new LinkedBlockingQueue<Document>(200000);
          
          
    --- 61,66 ----
    ***************
    *** 106,112 ****
              }
          }
     
    -     
          private Indexer(Properties prop)
          {
              _init(prop);
    --- 104,109 ----
    ***************
    *** 120,126 ****
                  {
                      prop = DaoDaoConfig.getProperties();
                  }
    -             //私有的构造方法供单例使用。
                  m_iInstance = new Indexer(prop);             
              }
              return m_iInstance;
    --- 117,122 ----

    示例2:对同行做修改。注意---部分格式的变化。

    diff -r -a -c -b -x Makefile.temp /home/gaoyibo/search/workspace/searchServer/src/com/daodao/servlet/Init.java /home/gaoyibo/php-site/php-site/src/Search/src/com/daodao/servlet/Init.java
    *** /home/gaoyibo/search/workspace/searchServer/src/com/daodao/servlet/Init.jav2011-11-08 19:51:56.000000000 +0800
    --- /home/gaoyibo/php-site/php-site/src/Search/src/com/daodao/servlet/Init.java2011-11-08 19:51:46.000000000 +0800
    ***************
    *** 32,38 ****
              // DaoDaoPostDBReader.getInstance();
              // get location related info
              long lStart = System.currentTimeMillis();
    !         // DaoDaoLocationReader.getInstance();
              long lSpan = System.currentTimeMillis() - lStart;
              lStart = System.currentTimeMillis();
              DaoDaoLogging.SERVLET.info("Loading all location info takes " + lSpan
    --- 32,38 ----
              // DaoDaoPostDBReader.getInstance();
              // get location related info
              long lStart = System.currentTimeMillis();
    !         DaoDaoLocationReader.getInstance();
              long lSpan = System.currentTimeMillis() - lStart;
              lStart = System.currentTimeMillis();
              DaoDaoLogging.SERVLET.info("Loading all location info takes " + lSpan
    ***************
    *** 48,54 ****
     
              if (DaoDaoConfig.getStringProperty(GEOPREFIXSEARCH).equalsIgnoreCase(
                      "true")) {
    ! //            GeoPrefixSearch.getInstance();
                  lSpan = System.currentTimeMillis() - lStart;
                  lStart = System.currentTimeMillis();
                  DaoDaoLogging.SERVLET.info("Loading all geo prefix index takes "
    --- 48,54 ----
     
              if (DaoDaoConfig.getStringProperty(GEOPREFIXSEARCH).equalsIgnoreCase(
                      "true")) {
    !             GeoPrefixSearch.getInstance();
                  lSpan = System.currentTimeMillis() - lStart;
                  lStart = System.currentTimeMillis();
                  DaoDaoLogging.SERVLET.info("Loading all geo prefix index takes

     
     
  • 相关阅读:
    P31 整体更新或新增 PUT
    P30 整体更新/替换资源 PUT
    P29 自定义错误信息和错误报告
    python: openpyxl带格式复制excel
    Android控件与布局——基础控件RadioButton
    EditText 使用详解
    Linux内核内存检测工具KASAN
    ISP基础(10)-Gamma校正及其实现
    ISP基础(08)-动态范围压缩
    ISP基础(07)-自动曝光
  • 原文地址:https://www.cnblogs.com/highriver/p/2241560.html
Copyright © 2011-2022 走看看