diff
1. Role
diff command comparison between the two files, and point out differences between the two, using its authority to all users.
2. Format
diff [options] 源文件 目标文件
3. [options] main parameters
- - <number of lines> Specifies how many lines of text to be displayed. This parameter must be used in conjunction with -c or -u parameters.
- -a progressive or --text diff preset will only compare text files.
- -b or --ignore-space-change does not check different space character.
- -B or --ignore-blank-lines blank lines does not check.
- -c show all context, and mark the differences.
- -C <line number> or --context <line number> with the implementation of "-c- <line number>" same instruction.
- -d or --minimal use different algorithms to smaller units for comparison.
- -D <macro name> or ifdef <macro name> Output format of the parameter can be used to pre-processor macros.
- Or -e --ed output format can be used for this parameter in the script file ed.
- -F format or similar -forward-ed ed output of the script file, the original file in order to display the differences.
- When -H --speed-large-files or large files, you can speed up.
- -l <character or string> or --ignore-matching-lines <character or string> specify if two files differ in a few lines, and these lines at the same time contains the option character or string , no difference between the two files are displayed.
- -i --ignore-case or a different letter are not checked.
- -l or --paginate the results handed over to pr program page.
- -n --rcs the comparison result or RCS format display.
- -N or --new-file When comparing directories, if a file A appears only in a directory, the default will be displayed:
- Only in directory: A file If you use the -N parameter, the file will diff A comparison with a blank document.
- -p If the comparison file for the C language program code files, show differences in the function name is located.
- -P or --unidirectional-new-file and -N similar, but only when the second directory contains a file does not have the first directory, the file will be compared with the blank document.
- -q or --brief show only whether the differences, does not show detailed information.
- -r or --recursive compare subdirectories.
- -s or --report-identical-files if found no difference, still display information.
- -S <file> or --starting-file <file> When comparing directories, start comparing from the specified file.
- -t or --expand-tabs in the output, expand the tab character.
- -T or --initial-tab in front of each line by tab characters to align.
- -u, -U <Sequence> or --unified = <series> combined in different ways to display the contents of the file.
- -v or --version display version information.
- -w or --ignore-all-space Ignore all white space characters.
- -W <width> or --width <width> -y parameter in use, specifies the column width.
- -x <filename or directory> or --exclude <filename or directory> does not compare the options specified file or directory.
- The -X-<file> or --exclude-from <file> You can save a file or directory type a text file, the text file and specify = <file> In.
- -y or --side-by-side display of document similarities and differences in a parallel manner.
- --help Displays help.
- --left-column -y parameter in use, if the two files in a same row of content, displays only the lines to the column on the left.
- --suppress-common-lines in use -y parameter, the only difference.
4. Application examples
(1) compare two files
[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" represents log2014.log log20143log files and rows and 3 differ in the content of line 8; "11,12d10" denotes the first file and more than 12 line 11 second file .
(2) output in parallel format
[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
Description:
- "|" Before and after the contents of the documents represent two different
- "<" Indicates the end of the file less than the preceding row of content files 1
- ">" Stands for file more than one row in front of the file contents