diff man page on 4.4BSD

Man page or keyword search:  
man Server   1065 pages
apropos Keyword Search (all sections)
Output format
4.4BSD logo
[printable version]

DIFF(1)			  BSD General Commands Manual		       DIFF(1)

NAME
     diff — differential file and directory comparator

SYNOPSIS
     diff [-cefhn] [-biwt] file1 file2
     diff [-Dstring] [-biw] file1 file2
     diff [-l] [-r] [-s] [-cefhn] [-biwt] [-Sname] dir1 dir2

DESCRIPTION
     The diff utility compares the contents of file1 and file2 and writes to
     the standard output the list of changes necessary to convert one file
     into the other.  No output is produced if the files are identical.

     Output options (mutually exclusive):

     -c	     produces a diff with lines of context.  The default is to present
	     3 lines of context and may be changed, e.g., to 10, by -c10.
	     With -c the output format is modified slightly: the output begin‐
	     ning with identification of the files involved and their creation
	     dates and then each change is separated by a line with a dozen
	     *'s.  The lines removed from file1 are marked with `− '; those
	     added to file2 are marked `+ '.  Lines which are changed from one
	     file to the other are marked in both files with `! '.  Changes
	     which lie within <context> lines of each other are grouped
	     together on output.  (This is a change from the previous ``diff
	     -c'' but the resulting output is usually much easier to inter‐
	     pret.)

     -e	     produces output in a form suitable as input for the editor util‐
	     ity, ed(1), which can then be used to convert file1 into file2.

	     Extra commands are added to the output when comparing directories
	     with -e, so that the result is a sh(1) script for converting text
	     files which are common to the two directories from their state in
	     dir1 to their state in dir2.

     -f	     identical output to that of the -e flag, but in reverse order.
	     It cannot be digested by ed(1).

     -h	     Invokes an alternate algorithm which can handle files of very
	     long lengths.  There is a trade off. The algorithm can only deal
	     with changes which are clearly delimited and brief. Long sections
	     of changes and overlaps will confuse it.

     -n	     produces a script similar to that of -e, but in the opposite
	     order and with a count of changed lines on each insert or delete
	     command.  This is the form used by rcsdiff(1).

     -Dstring
	     creates a merged version of file1 and file2 on the standard out‐
	     put, with C preprocessor controls included so that a compilation
	     of the result without defining string is equivalent to compiling
	     file1, while defining string will yield file2.

     Comparison options:

     -b	     causes trailing blanks (spaces and tabs) to be ignored, and other
	     strings of blanks to compare equal.

     -i	     ignores the case of letters.  E.g., ``A'' will compare equal to
	     ``a''.

     -t	     will expand tabs in output lines.	Normal or -c output adds char‐
	     acter(s) to the front of each line which may screw up the inden‐
	     tation of the original source lines and make the output listing
	     difficult to interpret.  This option will preserve the original
	     source's indentation.

     -w	     is similar to -b but causes whitespace (blanks and tabs) to be
	     totally ignored.  E.g., ``if ( a == b )'' will compare equal to
	     ``if(a==b)''.

     Directory comparison options:

     -l	     long output format; each text file diff´d is piped through pr(1)
	     to paginate it, other differences are remembered and summarized
	     after all text file differences are reported.

     -r	     causes application of diff recursively to common subdirectories
	     encountered.

     -s	     causes diff to report files which are the same, which are other‐
	     wise not mentioned.

     -Sname  re-starts a directory diff in the middle beginning with file
	     name.

     If both arguments are directories, diff sorts the contents of the direc‐
     tories by name, and then runs the regular file diff algorithm, producing
     a change list, on text files which are different.	Binary files which
     differ, common subdirectories, and files which appear in only one direc‐
     tory are described as such.

     If only one of file1 and file2 is a directory, diff is applied to the
     non-directory file and the file contained in the directory file with a
     filename that is the same as the last component of the non-directory
     file.

     If either file1 or file2 is ‘-’, the standard input is used in its place.

   Output Style
     The default (without -e, -c, or -n options) output contains lines of
     these forms, where XX, YY, ZZ, QQ are line numbers respective of file
     order.

     XXaYY	  At (the end of) line XX of file1, append the contents of
		  line YY of file2 to make them equal.
     XXaYY,ZZ	  Same as above, but append the range of lines, YY through ZZ
		  of file2 to line XX of file1.
     XXdYY	  At line XX delete the line. The value YY tells to which line
		  the change would bring file1 in line with file1.
     XX,YYdZZ	  Delete the range of lines XX through YY in file1.
     XXcYY	  Change the line XX in file1 to the line YY in file2.
     XX,YYcZZ	  Replace the range of specified lines with the line ZZ.
     XX,YYcZZ,QQ  Replace the range XX,YY from file1 with the range ZZ,QQ from
		  file2.

     These lines resemble ed(1) subcommands to convert file1 into file2.  The
     line numbers before the action letters pertain to file1; those after per‐
     tain to file2.  Thus, by exchanging a for d and reading the line in
     reverse order, one can also determine how to convert file2 into file1.
     As in ed(1), identical pairs (where num1 = num2) are abbreviated as a
     single number.

ENVIRONMENT
     TMPDIR  If the environment variable TMPDIR exists, diff will use the
	     directory specified by TMPDIR as the temporary directory.

FILES
     /tmp/d?????
     /usr/bin/diffh  Alternate algorithm version (used by option -h).
     /usr/bin/diff   for directory diffs
     /usr/bin/pr     used by the -l option.

SEE ALSO
     cmp(1), cc(1), comm(1), ed(1), diff3(1)

DIAGNOSTICS
     The diff utility exits with one of the following values:

	   0	   No differences were found.
	   1	   Differences were found.
	   >1	   An error occurred.

BUGS
     The -f and -e options do not provide special handling for lines on which
     the first and only character is “.”.  This can cause problems for ed(1).

     When comparing directories with the -b, -w or -i options specified, diff
     first compares the files ala cmp, and then decides to run the diff algo‐
     rithm if they are not equal.  This may cause a small amount of spurious
     output if the files then turn out to be identical because the only dif‐
     ferences are insignificant white space or case differences.

HISTORY
     A diff command appeared in Version 6 AT&T UNIX.

4th Berkeley Distribution	 June 30, 1993	     4th Berkeley Distribution
[top]

List of man pages available for 4.4BSD

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
...................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net