diff 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. .TH DIFF 1
  2. .SH NAME
  3. diff \- differential file comparator
  4. .SH SYNOPSIS
  5. .B diff
  6. [
  7. .B -efmnbwr
  8. ] file1 ... file2
  9. .SH DESCRIPTION
  10. .I Diff
  11. tells what lines must be changed in two files to bring them
  12. into agreement.
  13. If one file
  14. is a directory,
  15. then a file in that directory with basename the same as that of
  16. the other file is used.
  17. If both files are directories, similarly named files in the
  18. two directories are compared by the method of
  19. .I diff
  20. for text
  21. files and
  22. .IR cmp (1)
  23. otherwise.
  24. If more than two file names are given, then each argument is compared
  25. to the last argument as above.
  26. The
  27. .B -r
  28. option causes
  29. .I diff
  30. to process similarly named subdirectories recursively.
  31. When processing more than one file,
  32. .I diff
  33. prefixes file differences with a single line
  34. listing the two differing files, in the form of
  35. a
  36. .I diff
  37. command line.
  38. The
  39. .B -m
  40. flag causes this behavior even when processing single files.
  41. .PP
  42. The normal output contains lines of these forms:
  43. .IP "" 5
  44. .I n1
  45. .B a
  46. .I n3,n4
  47. .br
  48. .I n1,n2
  49. .B d
  50. .I n3
  51. .br
  52. .I n1,n2
  53. .B c
  54. .I n3,n4
  55. .PP
  56. These lines resemble
  57. .I ed
  58. commands to convert
  59. .I file1
  60. into
  61. .IR file2 .
  62. The numbers after the letters pertain to
  63. .IR file2 .
  64. In fact, by exchanging `a' for `d' and reading backward
  65. one may ascertain equally how to convert
  66. .I file2
  67. into
  68. .IR file1 .
  69. As in
  70. .IR ed ,
  71. identical pairs where
  72. .I n1
  73. =
  74. .I n2
  75. or
  76. .I n3
  77. =
  78. .I n4
  79. are abbreviated as a single number.
  80. .PP
  81. Following each of these lines come all the lines that are
  82. affected in the first file flagged by `<',
  83. then all the lines that are affected in the second file
  84. flagged by `>'.
  85. .PP
  86. The
  87. .B -b
  88. option causes
  89. trailing blanks (spaces and tabs) to be ignored
  90. and other strings of blanks to compare equal.
  91. The
  92. .B -w
  93. option causes all white-space to be removed from input lines
  94. before applying the difference algorithm.
  95. .PP
  96. The
  97. .B -n
  98. option prefixes each range with
  99. .IB file : \fR
  100. and inserts a space around the
  101. .BR a ,
  102. .BR c ,
  103. and
  104. .B d
  105. verbs.
  106. The
  107. .B -e
  108. option produces a script of
  109. .I "a, c"
  110. and
  111. .I d
  112. commands for the editor
  113. .IR ed ,
  114. which will recreate
  115. .I file2
  116. from
  117. .IR file1 .
  118. The
  119. .B -f
  120. option produces a similar script,
  121. not useful with
  122. .IR ed ,
  123. in the opposite order. It may, however, be
  124. useful as input to a stream-oriented post-processor.
  125. .PP
  126. Except in rare circumstances,
  127. .I diff
  128. finds a smallest sufficient set of file
  129. differences.
  130. .SH FILES
  131. .B /tmp/diff[12]
  132. .SH SOURCE
  133. .B /sys/src/cmd/diff
  134. .SH "SEE ALSO"
  135. .IR cmp (1),
  136. .IR comm (1),
  137. .IR ed (1)
  138. .SH DIAGNOSTICS
  139. Exit status is the empty string
  140. for no differences,
  141. .L some
  142. for some,
  143. and
  144. .L error
  145. for trouble.
  146. .SH BUGS
  147. Editing scripts produced under the
  148. .BR -e " or"
  149. .BR -f " option are naive about"
  150. creating lines consisting of a single `\fB.\fR'.
  151. .br
  152. When running
  153. .I diff
  154. on directories, the notion of what is a text
  155. file is open to debate.