zoukankan      html  css  js  c++  java
  • 文件不同 diff --brief XX YY

    文件不同

    diff --brief XX YY

    文件不同 --哪些位置

    diff -c XX YY

    9.diff命令

    diff命令用于比较多个文本文件的差异,格式为“diff [参数] 文件”。

    在使用diff命令时,不仅可以使用--brief参数来确认两个文件是否不同,还可以使用-c参数来详细比较出多个文件的差异之处,这绝对是判断文件是否被篡改的有力神器。例如,先使用cat命令分别查看diff_A.txt和diff_B.txt文件的内容,然后进行比较:

    [root@linuxprobe ~]# cat diff_A.txt
    Welcome to linuxprobe.com
    Red Hat certified
    Free Linux Lessons
    Professional guidance
    Linux Course
    [root@linuxprobe ~]# cat diff_B.txt
    Welcome tooo linuxprobe.com
    
    Red Hat certified
    Free Linux LeSSonS
    ////////.....////////
    Professional guidance
    Linux Course

    接下来使用diff --brief命令显示比较后的结果,判断文件是否相同:

    [root@linuxprobe ~]# diff --brief diff_A.txt diff_B.txt
    Files diff_A.txt and diff_B.txt differ
    

    最后使用带有-c参数的diff命令来描述文件内容具体的不同:

    [root@linuxprobe ~]# diff -c diff_A.txt diff_B.txt
    *** diff_A.txt 2017-08-30 18:07:45.230864626 +0800
    --- diff_B.txt 2017-08-30 18:08:52.203860389 +0800
    ***************
    *** 1,5 ****
    ! Welcome to linuxprobe.com
    Red Hat certified
    ! Free Linux Lessons
    Professional guidance
    Linux Course
    --- 1,7 ----
    ! Welcome tooo linuxprobe.com
    !
    Red Hat certified
    ! Free Linux LeSSonS
    ! ////////.....////////
    Professional guidance
    Linux Course
  • 相关阅读:
    116填充每个节点的下一个右侧节点指针
    115不同的子序列
    114.二叉树展开为链表
    LeetCode 面试题55
    LeetCode 110. 平衡二叉树
    LeetCode 152. 乘积最大子数组
    LeetCode 面试题58
    LeetCode 151. 翻转字符串里的单词
    LeetCode 25. K 个一组翻转链表
    LeetCode 面试题61. 扑克牌中的顺子
  • 原文地址:https://www.cnblogs.com/xuanbjut/p/11924396.html
Copyright © 2011-2022 走看看