DIFF(1) | MidnightBSD General Commands Manual | DIFF(1) |
diff
—
differential file and directory comparator
diff |
[-aBbdipTtw ] [-c |
-e | -f |
-n | -q |
-u | -y ]
[--brief ]
[--changed-group-format
GFMT] [--ed ]
[--expand-tabs ]
[--forward-ed ]
[--ignore-all-space ]
[--ignore-case ]
[--ignore-space-change ]
[--initial-tab ]
[--minimal ]
[--no-ignore-file-name-case ]
[--normal ] [--rcs ]
[--show-c-function ]
[--starting-file ]
[--speed-large-files ]
[--strip-trailing-cr ]
[--tabsize number]
[--text ] [--unified ]
[-I pattern |
--ignore-matching-lines
pattern] [-L
label | --label
label] file1 file2 |
diff |
[-aBbdilpTtw ] [-I
pattern |
--ignore-matching-lines
pattern] [-L
label | --label
label] [--brief ]
[--changed-group-format
GFMT] [--ed ]
[--expand-tabs ]
[--forward-ed ]
[--ignore-all-space ]
[--ignore-case ]
[--ignore-space-change ]
[--initial-tab ]
[--minimal ]
[--no-ignore-file-name-case ]
[--normal ] [--paginate ]
[--rcs ]
[--show-c-function ]
[--speed-large-files ]
[--starting-file ]
[--strip-trailing-cr ]
[--tabsize number]
[--text ] -C
number | -context
number file1 file2 |
diff |
[-aBbdiltw ] [-I
pattern |
--ignore-matching-lines
pattern] [--brief ]
[--changed-group-format
GFMT] [--ed ]
[--expand-tabs ]
[--forward-ed ]
[--ignore-all-space ]
[--ignore-case ]
[--ignore-space-change ]
[--initial-tab ]
[--minimal ]
[--no-ignore-file-name-case ]
[--normal ] [--paginate ]
[--rcs ]
[--show-c-function ]
[--speed-large-files ]
[--starting-file ]
[--strip-trailing-cr ]
[--tabsize number]
[--text ] -D
string | --ifdef
string file1 file2 |
diff |
[-aBbdilpTtw ] [-I
pattern |
--ignore-matching-lines
pattern] [-L
label | --label
label] [--brief ]
[--changed-group-format
GFMT] [--ed ]
[--expand-tabs ]
[--forward-ed ]
[--ignore-all-space ]
[--ignore-case ]
[--ignore-space-change ]
[--initial-tab ]
[--minimal ]
[--no-ignore-file-name-case ]
[--normal ] [--paginate ]
[--rcs ]
[--show-c-function ]
[--speed-large-files ]
[--starting-file ]
[--strip-trailing-cr ]
[--tabsize number]
[--text ] -U
number | --unified
number file1 file2 |
diff |
[-aBbdilNPprsTtw ] [-c |
-e | -f |
-n | -q |
-u ] [--brief ]
[--changed-group-format
GFMT] [--context ]
[--ed ] [--expand-tabs ]
[--forward-ed ]
[--ignore-all-space ]
[--ignore-case ]
[--ignore-space-change ]
[--initial-tab ]
[--minimal ] [--new-file ]
[--no-ignore-file-name-case ]
[--normal ] [--paginate ]
[--rcs ] [--recursive ]
[--report-identical-files ]
[--show-c-function ]
[--speed-large-files ]
[--strip-trailing-cr ]
[--tabsize number]
[--text ]
[--unidirectional-new-file ]
[--unified ] [-I
pattern |
--ignore-matching-lines
pattern]
[-L label | --label label]
[-S name | --starting-file name]
[-X file | --exclude-from file]
[-x pattern | --exclude pattern]
dir1 dir2 |
diff |
[-aBbditwW ] [--expand-tabs]
[--ignore-all-blanks] [--ignore-blank-lines] [--ignore-case] [--minimal]
[--no-ignore-file-name-case] [--strip-trailing-cr]
[--suppress-common-lines] [--tabsize number]
[--text] [--width] -y |
--side-by-side file1
file2 |
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
number --context
number-c
but produces a diff with
number lines of context.-c
-c
the output format is modified slightly: the output begins with
identification of the files involved and their creation dates and then
each change is separated by a line with fifteen
*
'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 3 lines of each other are grouped together on
output.-D
string --ifdef
string-e
--ed
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
--forward-ed
-e
flag, but in
reverse order. It cannot be digested by
ed(1).-n
-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).-q
--brief
-U
number --unified
number-u
but produces a diff with
number lines of context.-u
-c
option. However, unlike
with -c
, all lines to be changed (added and/or
removed) are present in a single section.-y
--side-by-side
Comparison options:
-a
--text
diff
will
simply print “Binary files ... differ” if files contain
binary characters. Use of this option forces diff
to produce a diff.-B
--ignore-blank-lines
-b
--ignore-space-change
-d
--minimal
-I
pattern
--ignore-matching-lines
pattern-I
patterns may be specified. All lines in the
change must match some pattern for the change to be ignored. See
re_format(7) for
more information on regular expression patterns.-i
--ignore-case
-l
--paginate
-L
label --label
label-p
--show-c-function
-T
--initial-tab
-t
--expand-tabs
-c
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
difficult to interpret. This option will preserve the original source's
indentation.-w
--ignore-all-blanks
-b
--ignore-space-change
but causes whitespace
(blanks and tabs) to be totally ignored. E.g., “if ( a == b
)” will compare equal to “if(a==b)”.-W
number --width
number--changed-group-format
GFMTthe format is a string with special keywords:
--ignore-file-name-case
--no-ignore-file-name-case
--normal
--speed-large-files
--strip-trailing-cr
--suppress-common-lines
--tabsize
numberDirectory comparison options:
-N
--new-file
-P
--unidirectional-new-file
-r
--recursive
diff
recursively to common
subdirectories encountered.-S
name --starting-file
namediff
in the middle,
beginning with file name.-s
--report-identical-files
diff
to report files which are the same,
which are otherwise not mentioned.-X
file --exclude-from
file-X
options may be specified.-x
pattern --exclude
pattern-x
options may be specified.If both arguments are directories, diff
sorts the contents of the directories 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 directory are described
as such. In directory mode only regular files and directories are compared.
If a non-regular file such as a device special file or FIFO is encountered,
a diagnostic message is printed.
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.
The default (without -e
,
-c
, or -n
--rcs
options) output contains lines of these forms,
where XX, YY,
ZZ, QQ are line numbers
respective of file order.
XX
a
YY
XX
a
YY,ZZ
XX
d
YY
XX,YY
d
ZZ
XX
c
YY
XX,YY
c
ZZ
XX,YY
c
ZZ,QQ
These lines resemble
ed(1) subcommands to convert
file1 into file2. The line
numbers before the action letters pertain to file1;
those after pertain 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.
The diff
utility exits with one of the
following values:
cmp(1), comm(1), diff3(1), ed(1), patch(1), pr(1), sdiff(1)
James W. Hunt and M. Douglas McIlroy, An Algorithm for Differential File Comparison, Computing Science Technical Report, Bell Laboratories 41, June 1976.
The diff
utility is compliant with the
IEEE Std 1003.1-2008 (“POSIX.1”)
specification.
The flags [-aDdIiLlNnPpqSsTtwXx
] are
extensions to that specification.
A diff
command appeared in
Version 6 AT&T UNIX.
June 1, 2020 | midnightbsd-3.1 |