[0m


DIFF(1)             UNIX Programmer's Manual		  DIFF(1)



[1mNAME
     [0mdiff - differential file and directory comparator

[1mSYNOPSIS
     diff [0m[ [1m-lrs [0m] [ [1m-S[0m_n_a_m_e ] [ [1m-cefhn [0m] [ [1m-biwt [0m] dir1 dir2
     [1mdiff [0m[ [1m-cefhn ] [ -biwt [0m] file1 file2
     [1mdiff [0m[ [1m-D[0m_s_t_r_i_n_g ] [ [1m-biw [0m] file1 file2

[1mDESCRIPTION
     [0mIf both arguments are directories, _d_i_f_f sorts the contents
     of the directories by name, and then runs the regular file
     _d_i_f_f algorithm (described below) on text files which are
     different.  Binary files which differ, common subdirec-
     tories, and files which appear in only one directory are
     listed.  Options when comparing directories are:

     [1m-l   [0mlong output format; each text file _d_i_f_f is piped
	  through _p_r(1) to paginate it, other differences are
	  remembered and summarized after all text file differ-
	  ences are reported.

     [1m-r   [0mcauses application of _d_i_f_f recursively to common sub-
	  directories encountered.

     [1m-s   [0mcauses _d_i_f_f to report files which are the same, which
	  are otherwise not mentioned.

     [1m-Sname
	  [0mstarts a directory _d_i_f_f in the middle beginning with
	  file _n_a_m_e.

     When run on regular files, and when comparing text files
     which differ during directory comparison, _d_i_f_f tells what
     lines must be changed in the files to bring them into agree-
     ment.  Except in rare circumstances, _d_i_f_f finds a smallest
     sufficient set of file differences.  If neither _f_i_l_e_1 nor
     _f_i_l_e_2 is a directory, then either may be given as `-', in
     which case the standard input is used.  If _f_i_l_e_1 is a direc-
     tory, then a file in that directory whose file-name is the
     same as the file-name of _f_i_l_e_2 is used (and vice versa).

     There are several options for output format; the default
     output format contains lines of these forms:

	  _n_1 a _n_3,_n_4
	  _n_1,_n_2 d _n_3
	  _n_1,_n_2 c _n_3,_n_4

     These lines resemble _e_d commands to convert _f_i_l_e_1 into
     _f_i_l_e_2.  The numbers after the letters pertain to _f_i_l_e_2.  In
     fact, by exchanging `a' for `d' and reading backward one may
     ascertain equally how to convert _f_i_l_e_2 into _f_i_l_e_1.  As in



Printed 22/5/92     Revision 1.6 of 09/11/90			1






DIFF(1)             UNIX Programmer's Manual		  DIFF(1)



     _e_d, identical pairs where _n_1 = _n_2 or _n_3 = _n_4 are abbreviated
     as a single number.

     Following each of these lines come all the lines that are
     affected in the first file flagged by `<', then all the
     lines that are affected in the second file flagged by `>'.

     Except for [1m-b, -w, -i [0mor [1m-t [0mwhich may be given with any of
     the others, the following options are mutually exclusive:

     [1m-e       [0mproduces a script of _a, _c and _d commands for the
	      editor _e_d, which will recreate _f_i_l_e_2 from _f_i_l_e_1.
	      In connection with [1m-e[0m, the following shell program
	      may help maintain multiple versions of a file.
	      Only an ancestral file ($1) and a chain of
	      version-to-version _e_d scripts ($2,$3,...) made by
	      _d_i_f_f need be on hand.  A `latest version' appears
	      on the standard output.

		      (shift; cat $*; echo '1,$p') | ed - $1

	      Extra commands are added to the output when compar-
	      ing directories with [1m-e, [0mso that the result is a
	      _s_h(1) script for converting text files which are
	      common to the two directories from their state in
	      _d_i_r_1 to their state in _d_i_r_2.

     [1m-f       [0mproduces a script similar to that of [1m-e, [0mnot useful
	      with _e_d, and in the opposite order.

     [1m-n       [0mproduces a script similar to that of [1m-e, [0mbut in the
	      opposite order and with a count of changed lines on
	      each insert or delete command.  This is the form
	      used by _r_c_s_d_i_f_f(1).

     [1m-c       [0mproduces a diff with lines of context.  The default
	      is to present 3 lines of context and may be
	      changed, e.g to 10, by [1m-c10[0m.  With [1m-c [0mthe output
	      format is modified slightly: the output beginning
	      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
	      _f_i_l_e_1 are marked with `- '; those added to _f_i_l_e_2
	      are marked `+ '.	Lines which are changed from one
	      file to the other are marked in both files with
	      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.)



Printed 22/5/92     Revision 1.6 of 09/11/90			2






DIFF(1)             UNIX Programmer's Manual		  DIFF(1)



     [1m-h       [0mdoes a fast, half-hearted job.  It works only when
	      changed stretches are short and well separated, but
	      does work on files of unlimited length.

     [1m-Dstring [0mcauses _d_i_f_f to create a merged version of _f_i_l_e_1 and
	      _f_i_l_e_2 on the standard output, with C preprocessor
	      controls included so that a compilation of the
	      result without defining _s_t_r_i_n_g is equivalent to
	      compiling _f_i_l_e_1, while defining _s_t_r_i_n_g will yield
	      _f_i_l_e_2.

     [1m-b       [0mcauses trailing blanks (spaces and tabs) to be
	      ignored, and other strings of blanks to compare
	      equal.

     [1m-w       [0mis similar to [1m-b [0mbut causes whitespace (blanks and
	      tabs) to be totally ignored.  E.g.,
	      ``if ( a == b )'' will compare equal to
	      ``if(a==b)''.

     [1m-i       [0mignores the case of letters.  E.g., ``A'' will com-
	      pare equal to ``a''.

     [1m-t       [0mwill expand tabs in output lines.  Normal or [1m-c
	      [0moutput adds character(s) to the front of each line
	      which may screw up the indentation of the original
	      source lines and make the output listing difficult
	      to interpret.  This option will preserve the origi-
	      nal source's indentation.

[1mFILES
     [0m/var/tmp/d?????
     /usr/lib/diffh used by _d_i_f_f to implement the [1m-h [0moption.
     /usr/bin/pr	 used by _d_i_f_f to implement the [1m-l [0moption.

[1mSEE ALSO
     [0mcmp(1), cc(1), comm(1), ed(1), diff3(1)

[1mDIAGNOSTICS
     [0mExit status is 0 for no differences, 1 for some, 2 for trou-
     ble.

[1mBUGS
     [0mEditing scripts produced under the [1m-e [0mor [1m-f [0moption are naive
     about creating lines consisting of a single `[1m.[0m'.

     When comparing directories with the [1m-b, -w [0mor [1m-i [0moptions
     specified, _d_i_f_f first compares the files ala _c_m_p, and then
     decides to run the _d_i_f_f algorithm 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 differ-
     ences are insignificant blank string or case differences.



Printed 22/5/92     Revision 1.6 of 09/11/90			3






DIFF(1)             UNIX Programmer's Manual		  DIFF(1)



     If a file has an incomplete last line (a line not terminated
     with a newline character) _d_i_f_f will ignore the line when
     doing the comparison.




















































Printed 22/5/92     Revision 1.6 of 09/11/90			4



[0m