176 lines · 3.0 KB · Text
RawDownload
.TH DIFF 1 .SH NAMEdiff \- differential file comparator.SH SYNOPSIS.B diff[.B -abcefmnrw] .I file1 ... file2.SH DESCRIPTION.I Difftells what lines must be changed in two files to bring theminto agreement.If one fileis a directory,then a file in that directory with basename the same as that ofthe other file is used.If both files are directories, similarly named files in thetwo directories are compared by the method of .I difffor textfiles and.IR cmp (1)otherwise.If more than two file names are given, then each argument is comparedto the last argument as above.The .B -roption causes.I diffto process similarly named subdirectories recursively.When processing more than one file, .I diffprefixes file differences with a single linelisting the two differing files, in the form ofa .I diffcommand line.The.B -mflag causes this behavior even when processing single files..PPThe normal output contains lines of these forms:.IP "" 5.I n1.B a.I n3,n4.br.I n1,n2.B d.I n3.br.I n1,n2.B c.I n3,n4.PPThese lines resemble.I 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 backwardone may ascertain equally how to convert .I file2into.IR file1 .As in .IR 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 `<', then all the lines that are affected in the second fileflagged by `>'..PPThe.B -boption causestrailing blanks (spaces and tabs) to be ignoredand other strings of blanks to compare equal.The.B -woption causes all white-space to be removed from input linesbefore applying the difference algorithm..PPThe.B -noption prefixes each range with .IB file : \fRand inserts a space around the .BR a ,.BR c ,and.B dverbs.The.B -eoption produces a script of.I "a, c"and .I dcommands for the editor.IR ed ,which will recreate.I file2from.IR file1 .The.B -foption produces a similar script,not useful with.IR ed ,in the opposite order. It may, however, beuseful as input to a stream-oriented post-processor..PPThe.B -coption includes three lines of context around eachchange, merging changes whose contexts overlap.In this mode,.I diffprints.L -and.L +instead of.L <and.L >because the former are easier to distinguish when mixed.The.B -aflag displays the entire file as context..PPExcept in rare circumstances,.I difffinds a smallest sufficient set of filedifferences..SH FILES.B /tmp/diff[12].SH SOURCE.B /sys/src/cmd/diff.SH "SEE ALSO".IR cmp (1),.IR comm (1),.IR ed (1),.IR idiff (1).SH DIAGNOSTICSExit status is the empty stringfor no differences,.L somefor some, and.L errorfor trouble..SH BUGSEditing scripts produced under the.BR -e " or".BR -f " option are naive about"creating lines consisting of a single `\fB.\fR'..PPWhen running.I diffon directories, the notion of what is a textfile is open to debate.