Changeset View
Changeset View
Standalone View
Standalone View
head/usr.bin/diff/diff.1
Show All 24 Lines | |||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | .\" 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 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
.\" SUCH DAMAGE. | .\" SUCH DAMAGE. | ||||
.\" | .\" | ||||
.\" @(#)diff.1 8.1 (Berkeley) 6/30/93 | .\" @(#)diff.1 8.1 (Berkeley) 6/30/93 | ||||
.\" $FreeBSD$ | .\" $FreeBSD$ | ||||
.\" | .\" | ||||
.Dd June 1, 2020 | .Dd June 19, 2020 | ||||
.Dt DIFF 1 | .Dt DIFF 1 | ||||
.Os | .Os | ||||
.Sh NAME | .Sh NAME | ||||
.Nm diff | .Nm diff | ||||
.Nd differential file and directory comparator | .Nd differential file and directory comparator | ||||
.Sh SYNOPSIS | .Sh SYNOPSIS | ||||
.Nm diff | .Nm diff | ||||
.Op Fl aBbdipTtw | .Op Fl aBbdipTtw | ||||
▲ Show 20 Lines • Show All 230 Lines • ▼ Show 20 Lines | |||||
flag, but in reverse order. | flag, but in reverse order. | ||||
It cannot be digested by | It cannot be digested by | ||||
.Xr ed 1 . | .Xr ed 1 . | ||||
.It 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. | insert or delete command. | ||||
This is the form used by | This is the form used by rcsdiff. | ||||
.Xr rcsdiff 1 . | |||||
.It Fl q -brief | .It Fl q -brief | ||||
Just print a line when the files differ. | Just print a line when the files differ. | ||||
Does not output a list of changes. | Does not output a list of changes. | ||||
.It Fl U Ar number Fl -unified Ar number | .It Fl U Ar number Fl -unified Ar number | ||||
Like | Like | ||||
.Fl u | .Fl u | ||||
but produces a diff with | but produces a diff with | ||||
.Ar number | .Ar number | ||||
▲ Show 20 Lines • Show All 318 Lines • ▼ Show 20 Lines | |||||
.Bl -tag -width Ds -offset indent -compact | .Bl -tag -width Ds -offset indent -compact | ||||
.It 0 | .It 0 | ||||
No differences were found. | No differences were found. | ||||
.It 1 | .It 1 | ||||
Differences were found. | Differences were found. | ||||
.It >1 | .It >1 | ||||
An error occurred. | An error occurred. | ||||
.El | .El | ||||
.Sh EXAMPLES | |||||
Compare | |||||
.Pa old_dir | |||||
and | |||||
.Pa new_dir | |||||
recursively generating an unified diff and treating files found only in one | |||||
of those directories as new files: | |||||
.Bd -literal -offset indent | |||||
$ diff -ruN /path/to/old_dir /path/to/new_dir | |||||
.Ed | |||||
.Pp | |||||
Same as above but excluding files matching the expressions | |||||
.Dq *.h | |||||
and | |||||
.Dq *.c : | |||||
.Bd -literal -offset indent | |||||
$ diff -ruN -x '*.h' -x '*.c' /path/to/old_dir /path/to/new_dir | |||||
.Ed | |||||
.Pp | |||||
Show a single line indicating if the files differ: | |||||
.Bd -literal -offset indent | |||||
$ diff -q /boot/loader.conf /boot/defaults/loader.conf | |||||
Files /boot/loader.conf and /boot/defaults/loader.conf differ | |||||
.Ed | |||||
.Pp | |||||
Assuming a file named | |||||
.Pa example.txt | |||||
with the following contents: | |||||
.Bd -literal -offset indent | |||||
FreeBSD is an operating system | |||||
Linux is a kernel | |||||
OpenBSD is an operating system | |||||
.Ed | |||||
.Pp | |||||
Compare stdin with | |||||
.Pa example.txt | |||||
excluding from the comparison those lines containing either | |||||
.Qq Linux | |||||
or | |||||
.Qq Open : | |||||
.Bd -literal -offset indent | |||||
$ echo "FreeBSD is an operating system" | diff -q -I 'Linux|Open' example.txt - | |||||
.Ed | |||||
.Sh SEE ALSO | .Sh SEE ALSO | ||||
.Xr cmp 1 , | .Xr cmp 1 , | ||||
.Xr comm 1 , | .Xr comm 1 , | ||||
.Xr diff3 1 , | .Xr diff3 1 , | ||||
.Xr ed 1 , | .Xr ed 1 , | ||||
.Xr patch 1 , | .Xr patch 1 , | ||||
.Xr pr 1 , | .Xr pr 1 , | ||||
.Xr sdiff 1 | .Xr sdiff 1 | ||||
Show All 23 Lines |