comm
[OPTION] FILE1 FILE2
This command compares two files and prints the results in three-column output for example,
unique to file 1unique to file2 common lines
The files must be sorted before comm can be used.
Example: To compare the entries in two database files, t1old.db and t1new.db, use
comm t1old.db t1new.db
cmp
OPTIONS FROM-FILE [TO-FILE]
-1 | Suppress printing of column 1. |
-2 | Suppress printing of column 2. |
-3 | Suppress printing of column 3. |
cmp compares two files and outputs the first byte and line number where they differ.
Use cmp, rather than diff, to compare binary files. |
Example: To compare file1.txt and file2.txt, skipping the initial 1024 bytes and including the characters in the display, use
cmp --ignore-initial=1024 -c file1 file2
-c | Include the differing characters in the display. |
--ignore-initial=BYTES | Skip over the specified number of bytes before beginning to compare. |
-l | Include the offsets and octal values of any differing bytes in the output. |
--print-chars | Include the differing characters in the output. |
--quiet, -s, --silent | Don't output anything. |
--verbose | Include offsets and octal values of any differing bytes in the output. |
-v, --version | Output the version number. |
diff
OPTIONS from-file to-file
Displays the differences between the two files specified on the command line.
Example: To display the difference between a file recently modified and an older version of the same file, use
diff source.c source.old
Example: To display the differences between a file recently modified and an older version of the same file, excluding any changes to VAR1, use
diff -exclude=VAR1 source.c source.old
-LINE_CNT | Include the specified number of lines of context when outputting differences. (This command is obsolete.) |
-a | Treat all files (including binaries) as text. |
-b | Do not report differences in amount of white space. |
-B | Do not report differences in number of blank lines. |
--binary | Perform comparisons in binary mode. |
--brief | Report only if differences exist; do not list differences. |
-c | Output using context format. |
-C LINES, --context[=LINES] | Output using context format, including the specified number of lines with each difference. |
--changed-group-format=FORMAT | Use FORMAT to output a line group containing differing lines from both files in if-then-else format. |
-d | Use a different (usually slower) algorithm, which may return fewer changes. |
-DNAME | Make merged "#ifdef" format output, conditional on the preprocessor macro NAME. |
-e, --ed | Format output as an "ed" script. |
--exclude=PATTERN | When performing a recursive comparison on subdirectories, ignore any whose names match PATTERN. |
--exclude-from=FILE | When performing a recursive comparison on subdirectories, ignore any whose names match the patterns contained in FILE. |
--expand-tabs | Convert tabs to some number of spaces. |
-f | Format output similar to an ed script, but has changes ordered as they appear in the file. |
-FREGEXP | Output, along with some surrounding lines (for context), any value that matches REGEXP. |
--forward-ed | Format output similar to an ed script, but has changes ordered as they appear in the file. |
-h | This option has no effect. It is included for backward compatibility. |
-H | Process files using heuristics. (It may speed processing of large files.) |
--horizon-lines=LINES | Do not discard the last LINES lines of the common prefix and the first LINES lines of the common suffix. |
-i | Treat upper- and lowercase letters as equivalent. |
-IREGEXP | Ignore changes that just insert or delete lines that match REGEXP. |
--ifdef=NAME | Make merged if-then-else output by using NAME. |
--ignore-all-space | Ignore any white spaces (including <TAB>s) when comparing lines. |
--ignore-blank-lines | Ignore any changes that involve entirely blank lines. |
--ignore-case | Treat upper- and lowercase letters as equivalent. |
--ignore-matching-lines =REGEXP | Ignore differences that involve lines matching REGEXP. |
--ignore-space-change | Ignore changes in the amount of white space. |
--initial-tab | Prefix a tab, instead of a space when formatting output. |
-l | Paginate output using "pr". |
-LLABEL | Substitute LABEL for the filename when outputting in context format. |
--label=LABEL | Substitute LABEL for the filename when outputting in context format. |
--left-column | When outputting in side-by-side format, output only the left column of two common lines. |
--line-format=FORMAT | Use the specified FORMAT to output all input lines. |
--minimal | Use a different algorithm to find a (possibly) smaller group of changes. |
-n | Format output in RCS format. |
-N, --new-file | When comparing directories, if a file exists in one, pretend it is (at least) present in other directories. |
--new-group-format=FORMAT | Output a group of lines taken from just the second file in if-then-else format. |
--new-line-format=FORMAT | Use FORMAT to output a line taken from just the second file in if-then-else format. |
--old-group-format=FORMAT | Use FORMAT to output a group of lines taken from just the first file in if-then-else format. |
--old-line-format=FORMAT | Use FORMAT to output a line taken from just the first file in if-then-else format. |
-p | When diffing C files, include the function name in any output. |
-P | When comparing directories, if a file appears only in the second directory of the two, treat it as present, but empty in the other. |
--paginate | Pass the output through "pr" to paginate it. |
-q | Report only whether the files differ, not the details of the differences. |
-r | When comparing directories, recursively compare any subdirectories found. |
--rcs | Output RCS-format diffs; like "-f", except that each command specifies the number of lines affected. |
--recursive | When comparing directories, recursively compare any subdirectories found. |
--report-identical-files | Report when two files are the same. |
-s | Report when two files are the same. |
-SFILE | Specify a start file to use when comparing directories. |
--sdiff-merge-assist | Include extra information (of use only to sdiff) in output. |
--show-c-function | When diffing C files, include the function name in any output. |
--show-function-line=REGEXP | When outputting in context or unified format, include some of the last preceding line that matches REGEXP. |
--side-by-side | Format output side by side. |
--speed-large-files | Use heuristics to speed handling of large files. |
--starting-file=FILE | When comparing directories, start with the specified FILE. |
--suppress-common-lines | When outputting in side-by-side format, do not print common lines. |
-t | Expand any tabs to spaces. |
-T | Prefix any output with a tab, rather than a space. |
--text | Treat all tiles (including binaries) as text. |
-u | Output using the unified output format. |
--unchanged-group-format=FORMAT | Use FORMAT to output a group of common lines taken from both files in if-then-else format. |
--unchanged-line-format =FORMAT | Use FORMAT to output a line common to both files in if-then-else format. |
--unidirectional-new-file | When comparing directories, if a file appears only in the second directory of the two, treat it as present, but empty in the other. |
-ULINES,--unified[=LINES] | Output in unified output format, displaying LINES lines of context. |
-v, --version | Output the version number of "diff". |
-w | Ignore white space when comparing lines. |
-W COLUMNS, --width=COLUMNS | Specifies an output width of COLUMNS when using side-by-side format. |
-xPATTERN | When comparing directories, skip over files and subdirectories whose names match PATTERN. |
-XFILE | When comparing directories, skip over files and subdirectories whose names match any pattern contained in FILE. |
diff3
OPTIONS MOD1 ORIGINAL MOD2
Compares three files. Any of the three may be standard input (specified by "-").
Example: To show the overlapping changes between three text files, use
diff3 -overlap-only f1.c f2.c f3.c
-a | Treat all files as text. |
-A | Incorporate all changes from ORIGINAL to MOD2 into MOD1. |
-e | Generate an "ed" script that incorporates all the changes from ORIGINAL to MOD2 into MOD1. |
-E | Generate an "ed" script as in -e option, but include bracket lines from first and third files of overlapping changes. |
--ed | Output an "ed" script that incorporates any changes from ORIGINAL to MOD2 into MOD1. |
--easy-only | Generate an "ed" script that incorporates all the changes from ORIGINAL to MOD2 into MOD1, but include only nonoverlapping changes. |
-i | Include commands at the end of any "ed" script. |
--initial-tab | Prefix any output with a tab, rather than spaces. |
-LLABEL,--label=LABEL | Use the specified LABEL for any brackets output by the -A, -E, or -X options. |
-m, --merge | Apply the edit script to the MOD1 file and send the result to standard output. |
--overlap-only | Generate an "ed" script that incorporates all the changes from ORIGINAL to MOD2 into MOD1, but output only changes that overlap. |
--show-all | Incorporate into MOD1 any changes from ORIGINAL to MOD2. Show overlaps with bracket lines. |
--show-overlap | Generate an "ed" script that incorporates all the changes from ORIGINAL to MOD2 into MOD1, except bracket lines from first and third files of overlapping changes. |
-T | Prefix any output with a TAB, rather than spaces. |
--text | Treat all files (including binaries) as text. |
-v, --version | Display the version number. |
-x | Generate an "ed" script that incorporates all the changes from ORIGINAL to MOD2 into MOD1, except output only the overlapping changes. |
-X | Generate an "ed" script that incorporates all the changes from ORIGINAL to MOD2 into MOD1, except output only the overlaping changes and surround changes with a bracket. |
-3 | Generate an "ed" script that incorporates all the changes from ORIGINAL to MOD2 into MOD1, except output only the nonoverlapping changes. |
sdiff
-o OUTFILE OPTIONS FROM-FILE TO-FILE
Merges two files and outputs the results to OUTFILE.
Example: To interactively merge the files source1 and source2 into the file result, use
sdiff -o result source1 source2
-a | Treat all files (including binaries) as text. |
-b | Do not consider changes in the amount of white space. |
-B | Do not consider changes involving blank lines. |
-d | Use a different algorithm that (may) return a smaller set of changes. |
-H | Use a heuristic designed to speed handling of large files. |
--expand-tabs | When outputting, expand tabs to spaces. |
-i | Treat uppercase and lowercase letters as equivalent. |
-IREGEXP | Do not consider addition/subtraction of lines which match REGEXP. |
--ignore-all-space | Ignore white space when comparing lines. |
--ignore-blank-lines | Ignore changes that just insert or delete blank lines. |
--ignore-case | Treat uppercase and lowercase letters as equivalent. |
--ignore-matching-lines=REGEXP | Do not consider addition/subtraction of lines which match REGEXP. |
--ignore-space-change | Ignore changes in amount of white space. |
-l, --left-column | Output only the left column of two common lines. |
--minimal | Use different algorithm that finds a smaller set of changes. |
-oFILE,--output=FILE | Send merged output to FILE. |
-s, --suppress-common-lines | Suppress output of common lines. |
--speed-large-files | Use a heuristic designed to speed handling of large files. |
-t | When outputting, expand tabs into spaces. |
--text | Treat all files (including binaries) as text. |
-v, --version | Display the version number. |
-w COLUMNS, --width=COLUMNS | Output using the specified column width. |
-W | Do not consider horizontal white space when comparing lines. |