diffutility will compare the contents of file1 and file2 and write to standard output a list of changes necessary to convert file1 into file2. This list should be minimal. Except in rare circumstances,
difffinds a smallest sufficient set of file differences. No output will be produced if the files are identical.
The normal output contains lines of these forms:
where n1 and n2 represent lines in file1 and n3 and n4 represent lines in file2 These lines resemble ed(1) commands to convert file1 to file2. By exchanging a for d and reading backwards, file2 can be converted to file1. As in ed(1), identical pairs, where n1=n2 or n3=n4 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 ‘>’.
-coutput adds character(s) to the front of each line that may adversely affect the indentation of the original source lines and make the output lines difficult to interpret. This option will preserve the original source's indentation.
if (a == b’) will compare equal to ‘
The following options are mutually exclusive:
-cwith number lines of context.
-eoption, the following shell program may help maintain multiple versions of a file. Only an ancestral file ($1) and a chain of version-to-version ed scripts ($2,$3,...) made by
diffneed be on hand. A “latest version” appears on the standard output.
(shift; cat $*; echo a'1,$p') | ed - $1
-nare unavailable with
diffdoes not descend into directories with this option.
-e, but in the opposite order and with a count of changed lines on each insert or delete command.
-coption, except that the context is “unified”. Removed and changed lines in file1 are marked by a ‘-’ while lines added or changed in file2 are marked by a ‘+’. Both versions of changed lines appear in the output, while added, removed, and context lines appear only once. The identification of file1 and file2 is different, with “---” and “+++” being printed where “***” and “---” would appear with the
-coption. Each change is separated by a line of the form
-uwith number lines of context.
The following options are used for comparing directories:
diff, each text file is piped through pr(1) to paginate it. Other differences are remembered and summarized after all text file differences are reported.
diffrecursively to common subdirectories encountered.
diffin the middle, beginning with the file name.
If only one of file1 and
file2 is a directory,
will be 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
diffwhen encountering files greater than or equal to 2 Gbyte (2^31 bytes).
In the following command, dir1 is a directory containing a directory named x, dir2 is a directory containing a directory named x, dir1/x and dir2/x both contain files named date.out, and dir2/x contains a file named y:
example% diff -r dir1 dir2 Common subdirectories: dir1/x and dir2/x Only in dir2/x: y diff -r dir1/x/date.out dir2/x/date.out 1c1 < Mon Jul 2 13:12:16 PDT 1990 --- > Tue Jun 19 21:41:39 PDT 1990
diffis Committed. The output of
-foptions are naïve about creating lines consisting of a single dot ‘.’.
Missing NEWLINE at end of file indicates that the last line of the file in question did not have a NEWLINE. If the lines are different, they will be flagged and output, although the output will seem to indicate they are the same.
|February 23, 2022||OmniOS|