Linux commands (ix) compare file differences diff

Source: Internet
Author: User
Tags diff

Diff Command Introduction

The diff command functions to compare two text files on a line-by-row basis, listing their differences. A system check is performed on the given file and shows all the different rows in the two files. If the diff command is followed by a directory, the file with the same name in the directory is compared, but its subdirectories are not compared.

Common parameter Description
-a 预设只会逐行比较文本文件-b 忽略行尾的空格-B 不检查空白行-c 用上下文输出格式,提供 n 行上下文-C 执行与 -c 命令相同-d 使用不同的演算法,以较小的单位来做比较-f 输出的格式类似于ed 的script,但按照原来文件的顺序来显示不同处-H 比较大文件时可以加快速度-l 若比较的文件在某几行有所不同,而这几行同时都包含了选项中指定的字符或字符串,则不显示这两个文件的差异。-i 不检查大小写的不同-I 讲结果交由 pr 程序来分页-n 将比较结果以 RCS 的格式来显示-N 在比较目录时,若文件 A 仅出现在某个目录中,则预设会显示。-p 若比较的文件为 C语言 的程序源文件时,则预设会显示-P 与 -N 类似,但只有当第二个目录包含了包含了第一个目录中没有的文件按时,才会将这个文件与空白的文件比较。-q 仅显示有无差异,不显示详细信息-r 比较子目录中的文件-s 若没有发现任何差异,任然显示信息-S 在比较目录时,从指定的文件开始比较-t 在输出时将 tab 字符展开-T 在每行前面加上tab 字符以便对齐-u,-U 以合并的方式来显示文件内容的不同-v 显示版本信息-w 忽略全部的空格字符-W 在使用 -y 参数时,指定栏宽-x 不比较选项中指定的文件或目录-X 可以将文件或目录类型存成文本文件,然后指定此文本文件-y 以并列的方式显示文件的异同之处--help 显示帮助
Instance
diff a.c  b.txt diff a.c  b.txt | cat -n

In the above results, the line that begins with the < first file, > the line that begins with the second file, and the letter A B C represents the additional delete modification operation (only C in the above results).

Linux commands (ix) compare file differences diff

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.