English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Der Linux diff-Befehl wird verwendet, um Dateidifferenzen zu vergleichen.
diff vergleicht Textdateienzeilenweise. Wenn ein Verzeichnis angegeben wird, vergleicht diff Dateien mit demselben Dateinamen, aber nicht die Unterordner.
diff [-abBcdefHilnNpPqrstTuvwy][-<Zeilennummer>][-C <Zeilennummer>][-D <Macro-Name>][-I <Zeichen oder Zeichenfolge>][-S <Datei>][-W <Breite>][-x <Datei oder Verzeichnis>][-X <Datei>][--help][--left-column][--suppress-common-line][Datei oder Verzeichnis1][Datei oder Verzeichnis2]
Parameter:
-<Zeilennummer> Bestimmt die Anzahl der anzuzeigenden Textzeilen. Dieser Parameter muss mit-oder-die Parameter 'u' gemeinsam verwenden.
-oder--text diff setzt nur eine Zeile für die Textdatei voraus.
-b oder--ignore-space-change 不检查空格字符的不同。
-B oder--ignore-blank-lines 不检查空白行。
-c 显示全部内文,并标出不同之处。
-C<行数> oder--context<行数> 与执行"-c-<行数>"指令相同。
-d oder--minimal 使用不同的演算法,以较小的单位来做比较。
-D<巨集名称> oder ifdef<巨集名称> 此参数的输出格式可用于前置处理器巨集。
-e oder--ed 此参数的输出格式可用于ed的script文件。
-f oder-forward-ed 输出的格式类似ed的script文件,但按照原来文件的顺序来显示不同处。
-H oder--speed-large-files 比较大文件时,可加快速度。
-l<字符或字符串> oder--ignore-matching-lines<字符或字符串> 若两个文件在某几行有所不同,而这几行同时都包含了选项中指定的字符或字符串,则不显示这两个文件的差异。
-i oder--ignore-case 不检查大小写的不同。
-l oder--paginate 将结果交由pr程序来分页。
-n oder--rcs 将比较结果以RCS的格式来显示。
-N oder--new-file Wenn Datei A im Vergleichsverzeichnis nur in einem bestimmten Verzeichnis vorhanden ist, wird standardmäßig angezeigt:
Nur in Verzeichnis:Wenn Datei A mit-N Parameter, dann wird diff die Datei A mit einer leeren Datei vergleichen.
-p Wenn die zu vergleichenden Dateien C-Programmcode-Dateien sind, wird der Name der Funktion angezeigt, in der sich die Unterschiede befinden.
-P oder--unidirectional-new-file mit-N ähnlich, aber nur wenn der zweite Verzeichnis eine Datei enthält, die im ersten Verzeichnis nicht vorhanden ist, wird diese Datei mit einer leeren Datei verglichen.
-q oder--brief 仅显示有无差异,不显示详细的信息。
-r oder--recursive 比较子目录中的文件。
-s oder--report-identical-files 若没有发现任何差异,仍然显示信息。
-S<文件> oder--starting-file<文件> 在比较目录时,从指定的文件开始比较。
-t oder--expand-tabs 在输出时,将tab字符展开。
-T oder--initial-tab 在每行前面加上tab字符以便对齐。
-u,-U<列数> oder--unified=<列数> 以合并的方式来显示文件内容的不同。
-v oder--version 显示版本信息。
-w or--ignore-all-space Ignore all space characters.
-W<width> or--width<width> When using-y parameter, specify column width.
-x<filename or directory> or--exclude<filename or directory> Do not compare the specified files or directories in the options.
-X<file> or--exclude-from<file> You can save the file or directory type as a text file, and then specify this text file in=<file>.
-y or--side-by-side Display the differences between files in parallel.
--help Display help.
--left-column When using-When using y parameter, if the content of a line in two files is the same, only the content in the left column is displayed.
--suppress-common-lines When using-When using y parameter, only the differences are displayed.
[root@localhost test3]# diff log2014.log log2013.log 3c3 < 2014-03 --- > 2013-03 8c8 < 2013-07 --- > 2013-08 11,12d10 < 2013-11 < 2013-12
The above"3c3" and"8c8" indicates log2014.log and log20143log file is in3Line and the8The line content is different;"11,12d10" indicates that the first file has more than the second file11And12Line.
[root@localhost test3]# diff log2014.log log2013.log -y -W 50 2013-01 2013-01 2013-02 2013-02 2014-03 | 2013-03 2013-04 2013-04 2013-05 2013-05 2013-06 2013-06 2013-07 2013-07 2013-07 | 2013-08 2013-09 2013-09 2013-10 2013-10 2013-11 < 2013-12 < [root@localhost test3]# diff log2013.log log2014.log -y -W 50 2013-01 2013-01 2013-02 2013-02 2013-03 | 2014-03 2013-04 2013-04 2013-05 2013-05 2013-06 2013-06 2013-07 2013-07 2013-08 | 2013-07 2013-09 2013-09 2013-10 2013-10 > 2013-11 > 2013-12
Note:
"|" indicates the content before and after2There are different contents in some files
"<" indicates that the file after it is smaller than the file before it1Line Content
">" indicates that the file after it is larger than the file before it1Line Content