version 1.1, 2003/06/25 01:20:52 |
version 1.2, 2003/06/25 01:23:30 |
|
|
.\" Copyright (c) 1980, 1990 The Regents of the University of California. |
.\" Copyright (c) 1980, 1990, 1993 |
.\" All rights reserved. |
.\" The Regents of the University of California. All rights reserved. |
.\" |
.\" |
.\" Redistribution and use in source and binary forms are permitted provided |
.\" Redistribution and use in source and binary forms, with or without |
.\" that: (1) source distributions retain this entire copyright notice and |
.\" modification, are permitted provided that the following conditions |
.\" comment, and (2) distributions including binaries display the following |
.\" are met: |
.\" acknowledgement: ``This product includes software developed by the |
.\" 1. Redistributions of source code must retain the above copyright |
.\" University of California, Berkeley and its contributors'' in the |
.\" notice, this list of conditions and the following disclaimer. |
.\" documentation or other materials provided with the distribution and in |
.\" 2. Redistributions in binary form must reproduce the above copyright |
.\" all advertising materials mentioning features or use of this software. |
.\" notice, this list of conditions and the following disclaimer in the |
.\" Neither the name of the University nor the names of its contributors may |
.\" documentation and/or other materials provided with the distribution. |
.\" be used to endorse or promote products derived from this software without |
.\" 3. All advertising materials mentioning features or use of this software |
.\" specific prior written permission. |
.\" must display the following acknowledgement: |
.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED |
.\" This product includes software developed by the University of |
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
.\" California, Berkeley and its contributors. |
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
.\" 4. Neither the name of the University nor the names of its contributors |
|
.\" may be used to endorse or promote products derived from this software |
|
.\" without specific prior written permission. |
.\" |
.\" |
.\" @(#)diff.1 6.6 (Berkeley) 7/24/90 |
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
.\" SUCH DAMAGE. |
.\" |
.\" |
.Dd July 24, 1990 |
.\" @(#)diff.1 8.1 (Berkeley) 6/30/93 |
|
.\" |
|
.Dd June 30, 1993 |
.Dt DIFF 1 |
.Dt DIFF 1 |
.Os BSD 4 |
.Os BSD 4 |
.Sh NAME |
.Sh NAME |
|
|
.Op Fl biwt |
.Op Fl biwt |
.Ar file1 file2 |
.Ar file1 file2 |
.Nm diff |
.Nm diff |
.Op Fl D Ar string |
.Op Fl D Ns Ar string |
.Op Fl biw |
.Op Fl biw |
.Ar file1 file2 |
.Ar file1 file2 |
.Nm diff |
.Nm diff |
|
|
.Op Fl s |
.Op Fl s |
.Op Fl cefhn |
.Op Fl cefhn |
.Op Fl biwt |
.Op Fl biwt |
|
.Op Fl S Ns Ar name |
.Ar dir1 dir2 |
.Ar dir1 dir2 |
.Sh DESCRIPTION |
.Sh DESCRIPTION |
The |
The |
|
|
No output is produced if the files are identical. |
No output is produced if the files are identical. |
.Pp |
.Pp |
Output options (mutually exclusive): |
Output options (mutually exclusive): |
.Tw Fl |
.Bl -tag -width Ds |
.Tp Fl c |
.It Fl c |
produces a diff with lines of context. |
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 |
The default is to present 3 lines of context and may be changed, e.g., to 10, by |
.Fl c10 . |
.Fl c10 . |
With |
With |
.Fl c |
.Fl c |
|
|
are marked with `\(mi '; those added to |
are marked with `\(mi '; those added to |
.Ar file2 |
.Ar file2 |
are marked `+ '. Lines which are changed from one |
are marked `+ '. Lines which are changed from one |
file to the other are marked in both files with with `! '. |
file to the other are marked in both files with `! '. |
Changes which lie within <context> lines of each other are grouped |
Changes which lie within <context> lines of each other are grouped |
together on output. (This is a change from the previous ``diff -c'' |
together on output. (This is a change from the previous ``diff -c'' |
but the resulting output is usually much easier to interpret.) |
but the resulting output is usually much easier to interpret.) |
.Tp Fl e |
.It Fl e |
produces output in a form suitable as input for the editor utility, |
produces output in a form suitable as input for the editor utility, |
.Xr ed 1 , |
.Xr ed 1 , |
which can then be used to convert file1 into file2. |
which can then be used to convert file1 into file2. |
|
|
.Ar dir1 |
.Ar dir1 |
to their state in |
to their state in |
.Ar dir2 . |
.Ar dir2 . |
.Tp Fl f |
.It Fl f |
identical output of the |
identical output to that of the |
.Fl e |
.Fl e |
flag, but in reverse order. It cannot |
flag, but in reverse order. It cannot |
be digested by |
be digested by |
.Xr ed 1 . |
.Xr ed 1 . |
.Tp Fl h |
.It Fl h |
Invokes an alternate algorithm which can handle files of very long lengths. |
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 |
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 |
clearly delimited and brief. Long sections of changes and overlaps will |
confuse it. |
confuse it. |
.Tp Fl n |
.It Fl n |
produces a script similar to that of |
produces a script similar to that of |
.Fl e , |
.Fl e , |
but in the opposite order and with a count of changed lines on each |
but in the opposite order and with a count of changed lines on each |
insert or delete command. This is the form used by |
insert or delete command. This is the form used by |
.Xr rcsdiff 1 . |
.Xr rcsdiff 1 . |
.Tc Fl D |
.It Fl D Ns Ar string |
.Ar string |
|
.Cx |
|
creates a merged version of |
creates a merged version of |
.Ar file1 |
.Ar file1 |
and |
and |
|
|
.Ar string |
.Ar string |
will yield |
will yield |
.Ar file2 . |
.Ar file2 . |
.Tp |
.El |
.Pp |
.Pp |
Comparison options: |
Comparison options: |
.Tp Fl b |
.Bl -tag -width Ds |
|
.It Fl b |
causes trailing blanks (spaces and tabs) to be ignored, and other |
causes trailing blanks (spaces and tabs) to be ignored, and other |
strings of blanks to compare equal. |
strings of blanks to compare equal. |
.Tp Fl i |
.It Fl i |
ignores the case of letters. E.g., ``A'' will compare equal to ``a''. |
ignores the case of letters. E.g., ``A'' will compare equal to ``a''. |
.Tp Fl t |
.It Fl t |
will expand tabs in output lines. Normal or |
will expand tabs in output lines. Normal or |
.Fl c |
.Fl c |
output adds character(s) to the front of each line which may screw up |
output 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 |
the indentation of the original source lines and make the output listing |
difficult to interpret. This option will preserve the original source's |
difficult to interpret. This option will preserve the original source's |
indentation. |
indentation. |
.Tp Fl w |
.It Fl w |
is similar to |
is similar to |
.Fl b |
.Fl b |
but causes whitespace (blanks and tabs) to be totally ignored. E.g., |
but causes whitespace (blanks and tabs) to be totally ignored. E.g., |
``if\ (\ a\ ==\ b\ )'' will compare equal to ``if(a==b)''. |
``if\ (\ a\ ==\ b\ )'' will compare equal to ``if(a==b)''. |
.Tp |
.El |
.Pp |
.Pp |
Directory comparison options: |
Directory comparison options: |
.Tw Fl |
.Bl -tag -width Ds |
.Tp Fl l |
.It Fl l |
long output format; each text file |
long output format; each text file |
.Sf Nm diff \'d |
.Nm diff Ns \'d |
is piped through |
is piped through |
.Xr pr 1 |
.Xr pr 1 |
to paginate it, |
to paginate it, |
other differences are remembered and summarized |
other differences are remembered and summarized |
after all text file differences are reported. |
after all text file differences are reported. |
.Tp Fl r |
.It Fl r |
causes application of |
causes application of |
.Nm diff |
.Nm diff |
recursively to common subdirectories encountered. |
recursively to common subdirectories encountered. |
.Tp Fl s |
.It Fl s |
causes |
causes |
.Nm diff |
.Nm diff |
to report files which are the same, which are otherwise not mentioned. |
to report files which are the same, which are otherwise not mentioned. |
.Tc Fl S |
.It Fl S Ns Ar name |
.Ar name |
|
.Cx |
|
re-starts a directory |
re-starts a directory |
.Nm diff |
.Nm diff |
in the middle beginning with file |
in the middle beginning with file |
.Ar name . |
.Ar name . |
.Tp |
.El |
.Pp |
.Pp |
If both arguments are directories, |
If both arguments are directories, |
.Nm diff |
.Nm diff |
|
|
the directory file with a filename that is the same as the |
the directory file with a filename that is the same as the |
last component of the non-directory file. |
last component of the non-directory file. |
.Pp |
.Pp |
If either the |
If either |
.Ar file1 |
.Ar file1 |
or |
or |
.Ar file2 |
.Ar file2 |
is |
is |
.Fl , |
.Sq Fl , |
the standard input is |
the standard input is |
used in its place. |
used in its place. |
.Ss Output Style |
.Ss Output Style |
|
|
.Va XX , YY , ZZ , QQ |
.Va XX , YY , ZZ , QQ |
are line numbers respective of file order. |
are line numbers respective of file order. |
.Pp |
.Pp |
.Dp Cx Li XX |
.Bl -tag -width "XX,YYcZZ,QQ" -compact |
.Ic a |
.It Li XX Ns Ic a Ns Li YY |
.Li YY |
|
.Cx |
|
At (the end of) line |
At (the end of) line |
.Va XX |
.Va XX |
of |
of |
|
|
of |
of |
.Ar file2 |
.Ar file2 |
to make them equal. |
to make them equal. |
.Dp Cx Li XX |
.It Li XX Ns Ic a Ns Li YY,ZZ |
.Ic a |
|
.Li YY , |
|
.Li ZZ |
|
.Cx |
|
Same as above, but append the range of lines, |
Same as above, but append the range of lines, |
.Va YY |
.Va YY |
through |
through |
|
|
to line |
to line |
.Va XX |
.Va XX |
of file1. |
of file1. |
.Dp Cx Li XX |
.It Li XX Ns Ic d Ns Li YY |
.Ic d |
|
.Li YY |
|
.Cx |
|
At line |
At line |
.Va XX |
.Va XX |
delete |
delete |
|
|
.Ar file1 |
.Ar file1 |
in line with |
in line with |
.Ar file1 . |
.Ar file1 . |
.Dp Cx Li XX , |
.It Li XX,YY Ns Ic d Ns Li ZZ |
.Li YY |
|
.Ic d |
|
.Li ZZ |
|
.Cx |
|
Delete the range of lines |
Delete the range of lines |
.Va XX |
.Va XX |
through |
through |
.Va YY |
.Va YY |
in |
in |
.Ar file1 . |
.Ar file1 . |
.Dp Cx Li XX |
.It Li XX Ns Ic c Ns Li YY |
.Ic c |
|
.Li YY |
|
.Cx |
|
Change the line |
Change the line |
.Va XX |
.Va XX |
in |
in |
|
|
.Va YY |
.Va YY |
in |
in |
.Ar file2. |
.Ar file2. |
.Dp Cx Li XX , |
.It Li XX,YY Ns Ic c Ns Li ZZ |
.Li YY |
|
.Ic c |
|
.Li ZZ |
|
.Cx |
|
Replace the range of specified lines with the line |
Replace the range of specified lines with the line |
.Va ZZ . |
.Va ZZ . |
.Dp Cx Li XX , |
.It Li XX,YY Ns Ic c Ns Li ZZ,QQ |
.Li YY |
|
.Ic c |
|
.Li ZZ , |
|
.Li QQ |
|
.Cx |
|
Replace the range |
Replace the range |
.Cx Va XX , |
.Va XX , Ns YY |
.Va YY |
|
.Cx |
|
from |
from |
.Ar file1 |
.Ar file1 |
with the range |
with the range |
.Cx Va ZZ , |
.Va ZZ , Ns QQ |
.Va QQ |
|
.Cx |
|
from |
from |
.Ar file2 . |
.Ar file2 . |
.Dp |
.El |
.Pp |
.Pp |
These lines resemble |
These lines resemble |
.Xr ed 1 |
.Xr ed 1 |
|
|
pairs (where num1 = num2) are abbreviated as a single |
pairs (where num1 = num2) are abbreviated as a single |
number. |
number. |
.Sh ENVIRONMENT |
.Sh ENVIRONMENT |
.Tw Fl |
.Bl -tag -width TMPDIR |
.Tp Ev TMPDIR |
.It Ev TMPDIR |
If the environment variable |
If the environment variable |
.Ev TMPDIR |
.Ev TMPDIR |
exists, |
exists, |
.Nm Diff |
.Nm diff |
will use the name specified by |
will use the directory specified by |
.Ev TMPDIR |
.Ev TMPDIR |
as an alternate temporary directory. |
as the temporary directory. |
.Tp |
.El |
.Sh FILES |
.Sh FILES |
.Dw /usr/bin/diffh |
.Bl -tag -width /usr/bin/diffh -compact |
.Di L |
.It Pa /tmp/d????? |
.Dp Pa /tmp/d????? |
.It Pa /usr/bin/diffh |
.br |
|
.Dp Pa /usr/bin/diffh |
|
Alternate algorithm version (used by option |
Alternate algorithm version (used by option |
.Fl h ) . |
.Fl h ) . |
.Dp Pa /usr/bin/diff |
.It Pa /usr/bin/diff |
for directory diffs |
for directory diffs |
.Dp Pa /usr/bin/pr |
.It Pa /usr/bin/pr |
used by the |
used by the |
.Fl l |
.Fl l |
option. |
option. |
.Dp |
.El |
.Sh SEE ALSO |
.Sh SEE ALSO |
.Xr cmp 1 , |
.Xr cmp 1 , |
.Xr cc 1 , |
.Xr cc 1 , |
.Xr comm 1 , |
.Xr comm 1 , |
.Xr ed 1 , |
.Xr ed 1 , |
.Xr diff3 1 |
.Xr diff3 1 |
.Sh HISTORY |
.br |
.Nm Diff |
.ne 1i |
appeared in Version 6 AT&T Unix. |
|
.Sh DIAGNOSTICS |
.Sh DIAGNOSTICS |
The |
The |
.Nm diff |
.Nm diff |
utility exits with one of the following values: |
utility exits with one of the following values: |
.Dw Ds |
.Pp |
.Dp \&0 |
.Bl -tag -width Ds -compact -offset indent |
|
.It \&0 |
No differences were found. |
No differences were found. |
.Dp \&1 |
.It \&1 |
Differences were found. |
Differences were found. |
.Dp \&>\&1 |
.It "\&>\&1" |
An error occurred. |
An error occurred. |
.Dp |
.El |
.Sh BUGS |
.Sh BUGS |
The |
The |
.Fl f |
.Fl f |
|
|
This may cause a small amount of spurious output if the files |
This may cause a small amount of spurious output if the files |
then turn out to be identical because the only differences are |
then turn out to be identical because the only differences are |
insignificant white space or case differences. |
insignificant white space or case differences. |
.\" .Sh STANDARDS |
.Sh HISTORY |
|
A |
|
.Nm |
|
command appeared in |
|
.At v6 . |