diff [options] old-file new-file
Use - to read from standard input. As a special case, diff - - compares a copy of standard input to itself.
diff directory file
Compares the corresponding file in directory . The non-directory file must not be - .
diff directory directory
Compares corresponding files in both directories, in alphabetical order.
This comparison is not recursive unless the -r or ‑‑recursive option is given.
diff never compares the actual contents of a directory as if it were a
file. The file that is fully specified may not be standard input,
because standard input is nameless and the notion of "file with the same name" does not apply.
Use -- to terminate options when specifing file names which begin with a -.
Multiple single letter options can be combined (example: ‑wyW50)
-i,--ignore-case
-B,--ignore-blank-lines Ignore changes that just insert or delete Blank lines.
-b,--ignore-space-change Ignore changes in amount of blanks.
-w,--ignore-all-space Ignore white space when comparing lines.
-q --brief Do not show differences.
quite only whether the files differ, not the details of the differences. Check the return code $?
-I regexp,
--ignore-matching-lines= regexp Ignore changes that just insert or delete lines that match regexp.
-d, --minimal, Change the algorithm to perhaps find a smaller set of changes.
slower (sometimes much slower).
-H,
--speed-large-files Use Heuristics to speed handling of large files that have numerous scattered small changes.
--side-by-side, -y diff -y /tmp/dfdf /tmp/dfdf_1 Avail Mounted Avail Mounted 695M / 695M / 170M /Volumes/DATA 170M /Volumes/DATA 56K /Volumes/BACKUP_2 56K /Volumes/BACKUP_2 919M /Volumes/TBD | 898M /Volumes/TBD xxxx xxxx -W columns,--width=columns diff -yW70 /tmp/dfdf /tmp/dfdf_1 Avail Mounted Avail Mounted 695M / 695M / 170M /Volumes/DATA 170M /Volumes/DATA 56K /Volumes/BACKUP_2 56K /Volumes/BACKUP_2 919M /Volumes/TBD | 898M /Volumes/TBD xxxx xxxx --suppress-common-lines diff -wyW$COLUMNS --su /tmp/dfdf /tmp/dfdf_1 --leftcolumn only
diff -yW60 --left /tmp/dfdf /tmp/dfdf_1 Avail Mounted ( 695M / ( 170M /Volumes/DATA ( 56K /Volumes/BACKUP_2 ( 919M /Volumes/TBD | 898M /Volumes/TBD xxxx ( |
|
When comparing directories: | |
-s,--report-identical-files | Report are identical when files are the same, otherwise no output is produced. |
-x pattern ,--exclude=pattern | ignore files and subdirectories whose basenames match pattern. |
--exclude-from=file
| ignore files and subdirectories whose basenames match any pattern in file. |
-X file | ignore files and subdirectories whose basenames match any pattern contained in file. |
-r,--recursive | compare subdirectories . |
-N,--new-file | a file found in only in one directory is compared to an empty file. |
-P,--unidirectional-new-file | a file occuring only in the second directory id compared to an empty file. |
-S file ,--starting-file=file
| start with the file file. Use for resuming an aborted comparison. |
-c Use the context output format, i.e. show the differences with some lines before and after.
-C lines,
--context=lines. show lines of context. Default 3.
diff -c /tmp/dfdf /tmp/dfdf_1 *** /tmp/dfdf Tue Sep 5 18:10:15 2006 --- /tmp/dfdf_1 Tue Sep 5 18:10:24 2006 *************** *** 4,7 **** 1.3G /Volumes/PHOTOS_1 2.7G /Volumes/PHOTOS_2 56K /Volumes/BACKUP_2 ! 919M /Volumes/TBD --- 4,7 ---- 1.3G /Volumes/PHOTOS_1 2.7G /Volumes/PHOTOS_2 56K /Volumes/BACKUP_2 ! 898M /Volumes/TBD
-e,
--ed Make output that is a valid ed script.
diff -e /tmp/dfdf /tmp/dfdf_1 7c 898M /Volumes/TBD .
-f,
--forward-ed Make output that looks vaguely like an ed script but has changes in the order they appear in the file.
diff -f /tmp/dfdf /tmp/dfdf_1 c7 898M /Volumes/TBD .
-F regexp In context and unified format, for each hunk of differences, show some of the last preceding line that matches regexp.
-n,
--rcs Output RCS-format(Revision Control Systems) diffs; like -f except that each command specifies the number of lines affected.
diff -n /tmp/dfdf /tmp/dfdf_1 d7 1 a7 1 898M /Volumes/TBD
-L label,
--label=label
Use label instead of the file name in the context and unified format headers.
-D name,--ifdef=name Make merged if-then-else format output, conditional on the preprocessor macro name.
diff --line-format="%8dn %L" /tmp/dfdf /tmp/dfdf_1 --old-line-format=format... a line taken from just the first file --new-line-format=format ...a line taken from just the second file --unchanged-line-format=format ... a line common to both files
--changed-group-format=format Use format to output a line group containing differing lines from both files --old-group-format=format ... the first file --new-group-format=format ...the second --unchanged-group-format=format ... of common lines from both files |
-u Use the unified output format.-U lines,--unified[=lines] Use the unified output format, showing lines of context. default 3.
|
-p,--show-c-function
| |
regexp |
In context and unified format, for each hunk of differences,
show some of the last preceding line that matches regexp.
|
lines | Do not discard the last lines lines of the common prefix and the first lines lines of the common suffix. |
-t,--expand-tabs | to spaces in the output, to preserve the alignment of tabs in the input files. |
-T,--initial-tab | Output a Tab rather than a space before the text of a line in normal or context format. This causes the alignment of tabs in the line to look normal. |
--from-file= file | Compare file to all operands. file can be a directory. |
--to-file= file | Compare all operands to file. file can be a directory. |
-l, --paginate | Pass the output through pr to paginate it.
|
-a, --text | Treat all files as ASCII text and compare them line-by-line, even if they do not seem to be text.
|
-v, --version
|
--sdiff-merge-assist
Print extra information to help sdiff. sdiff uses this option
when it runs diff. This option is not intended for users to use directly.
DIAGNOSTICS exit status
0 no differences were found, 1 some differences were found, and 2 means trouble ( file not found/accessible,...).
|
|
comm [OPTION]... FILE1 FILE2Compare sorted files FILE1 and FILE2 line by line displaying lines in common.
With no options, produce three-column output.
-1 suppress lines unique to FILE1 (first column)
--help
|