zoukankan      html  css  js  c++  java
  • 26、linux shell常用的几个函数,diff

    1、diff

    1)Name

    diff - find differences between two files

    Synopsis

    diff [options] from-file to-file

    Description

    In the simplest case, diff compares the contents of the two files from-file and to-file.

    2)option

        a single letter preceded by -, and the other of which is a long name preceded by --. Multiple single letter options (unless they take an argument) can be combined into a single command line word: -ac is equivalent to -a -c. Long named options can be abbreviated to any unique prefix of their name. Brackets ([ and ]) indicate that an option takes an optional argument.

    (1) -a:将所有文件当作文本文件来进行比较by line

    (2) -b 忽略空格

       -B 忽略空行

      -H 利用试探法加速对大文件的搜索

       -i 忽略大小写

       -r 比较目录中的文件

       -N 将不存在的文件当作空文件处理

       -u 使用 unified 格式。-U《列数》或–unified=《列数》,以合并的方式来显示文件内容的不同。

       -y Use the side by side output format.

          --left-column 使用-y参数时,若两个文件某一行内容相同,则仅在左侧栏位显示该行内容。

          --suppress-common-lines 使用-y参数时,仅显示不同之处。

       -W columns Use an output width of columns in side by side format.使用y参数时使用。

       -T 在每行前面加上tab字符以便对齐

       -p 若比较的文件为C语言的程序码文件时,显示差异所在的函数名称。

       -c 显示全部内文,并标出不同之处。

       -q 仅显示是否相同

    3)示例

    (1) diff test test2

        以小于号开始的就是第一个文件中存存的,以大于号开始的就是在第二个文件中出现的。字母adc分别表示附加、删除和修改操作。diff能区别块和字符设备文件以及FIFO(管道文件),不会把它们与普通文件进行比较。

    (2)  diff -i -y -W 80 test test1

    参考

    1http://www.flatws.cn/article/program/shell/2011-02-23/14053.html

    2http://linux.die.net/man/1/diff

    3】 对参数进行了很好解释

    http://www.phpzixue.cn/detail976.shtml

    http://www.wycode.com/linux/shell/2011/0809/1404.html

    4http://www.isstudy.com/linux/387.html

  • 相关阅读:
    IfcLightSourceSpot
    IfcLightSourcePositional
    IfcLightSourceGoniometric
    IfcLightSourceDirectional
    IfcLightSourceAmbient
    IfcLightSource
    从一系列的图片文件夹中随机抽取图片
    IfcPolygonalBoundedHalfSpace
    IfcBoxedHalfSpace
    IfcHalfSpaceSolid
  • 原文地址:https://www.cnblogs.com/mydomain/p/2191183.html
Copyright © 2011-2022 走看看