📄 diff.1
字号:
.TH diff 1.SH Namediff \- differential file comparator.SH Syntax\fBdiff\fP [\fIoptions\fR] \fIdir1 dir2\fR.br\fBdiff\fP [\fIoptions\fR] \fIfile1 file2\fR.SH Description.NXR "diff command".NXR "file" "comparing".NXR "directory" "comparing"The .PN diffcommand compares the contents of files or groups of files, and lists any differences it finds. When run on regular files, and when comparing text files that differduring directory comparison,.PN difftells what lines must be changedin the files to bring them into agreement.Except in rare circumstances,.PN difffinds a smallest sufficient set of file differences.If neither.I file1nor.I file2is a directory, then eithercan be specified as `\-', in which case the standard input is used.If.I file1is a directory,then a file in that directory whosefilename is the same as the filename of.I file2is used and likewise if .I file2is a directory..PPIf both arguments are directories,.PN diffsorts the contents of the directories by name, and then runs theregular file.PN diffalgorithm on text files that are different.Binary files that differ,common subdirectories, and files that appear in only one directoryare listed..SH OptionsThe following options are used when comparing directories:.IP \-l 10Displays the output in long format. Each text fileis piped through.MS pr 1to paginate it;other differences are summarizedafter all text file differences are reported..IP \-nProduces a script similar to that of.B \-e,but in reverse order and with a count of changed lineson each insert or delete command..IP \-rRecursively checks files in common subdirectories..IP \-sDisplays names of files that are the same. .IP \-S\fIname\fRStarts a directory in the middle beginning with the specified file..PPExcept for the.B \-b, i, t, and woptions,which may be given with any of the others,the following formatting options are mutually exclusive:.IP \-b 10 Ignores trailing blanks and otherstrings of blanks and treats such portions as equal..IP \-cDisplays three context lines with each output line. For backwards compatibility, \fB\-c\fIn\fRcauses \fBn\fR number of context lines..IP \-C\fI\ n\fR Displays specified number of context lines with each output line. With.B \-cor.B \-Cthe output format is modified slightly:the output begins with identification of the files involved andtheir creation dates and then each change is separatedby a line with a dozen asterisks (*).The lines removed from.I file1are marked with minus sign (-); those added to.I file2are marked plus sign (+). Lines that are changed from onefile to the other are marked in both files with an exclamation point (!)..IPChanges within .I ncontext lines of each other are groupedtogether in the output. This results in output that is usually much easier to interpret..IP \-D\fIstring\fR Causes.PN diffto create a merged version of.I file1and.I file2on the standard output. With C preprocessor controls included, a compilation of the result without defining \fIstring\fR is equivalentto compiling.I file1,while defining.I stringwill yield.I file2..IP \-e Writes output to an .PN ed script. In connection with.BR \-e ,the following shell program can help maintainmultiple versions of a file.Only an ancestral file ($1) and a chain of version-to-version.PN edscripts ($2,$3,...) made by.PN diffneed be available.A latest version message appears onthe standard output..EX (shift; cat $*; echo \'1,$p\') \(bv ed \- $1.EEIf you specify .B \-ewhen comparing directories the result is a .MS sh 1 script for converting text files that are common to the two directories from their state in.I dir1to their state in.I dir2..IP \-f Writes the output in reverse order to a script. .IP \-h Makes a hasty comparison. It works only when changed portions are shortand well separated,but does work on files of unlimited length..IP \-iIgnores the case of letters. For example 'A' will compare equal to `a'..IP \-tExpand tabs in output lines. Normal or.B \-coutput adds character(s) to the front of each line which may affect the indentation of the original source lines and make the output listing difficult to interpret. This option will preserves the original indentation..IP \-wCauses whitespace (blanks and tabs) to be totally ignored. For example, `if\ (\ a\ ==\ b\ )' will compare equal to `if(a==b)'..PPThere are several options for output format;the default output format contains lines of these forms:.IP "" 5.I n1a.I n3,n4.br.I n1,n2d.I n3.br.I n1,n2c.I n3,n4.PPThese lines resemble.PN edcommands to convert.I file1into.IR file2 .The numbers after the letters pertain to.IR file2 .In fact, by exchanging `a' for `d' and reading backwardyou can tell how to convert .I file2into.IR file1 .As in .PN ed ,identical pairs where.I n1=.I n2or.I n3=.I n4are abbreviated as a single number..PPFollowing each of these lines come all the lines that areaffected in the first file flagged by a left angle bracket (<).Then all the lines that are affected in the second file are listed,flagged by a right angle bracket (>)..SH Restrictions.NXR "diff command" "restricted"Editing scripts produced under the.B \-e or.B \-f option have troublecreating lines consisting of a single period (.)..PPWhen comparing directories with the.B \-b, i, t, or woptions specified,.PN difffirst compares the files as.PN cmpdoes, and then runs the.PN diffalgorithm if they are not equal.If the only differences are in the blank strings,.PN diffmay report these as differences. .SH Diagnostics.NXR "diff command" "diagnostics"Exit status is 0 for no differences, 1 for some differences,and 2if the specified file cannot be found..SH Files.TP 20.PN /tmp/d?????.TP.PN/usr/lib/diffh for .B \-h.TP.PN /bin/pr.SH See Alsocc(1), cmp(1), comm(1), diff3(1), ed(1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -