GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing ss64.com — diff Man Page - Linux diffDisplay the differences between two files, or each corresponding
file in two directories. Syntax
diff [options] FILES
Options Multiple single letter options (unless they take an argument) can be combined into a single command line word: so '-ac' is equivalent to '-a -c'. FILES are 'FILE1 FILE2' or 'DIR1 DIR2' or 'DIR FILE...' or 'FILE... DIR'.
If --from-file or --to-file is given, there are no restrictions on FILES.
If a FILE is '-', read standard input.
-a
--text
Treat all files as text.
-B
--ignore-blank-lines
Ignore changes whose lines are all blank.
-b
--ignore-space-change
Ignore changes in the amount of white space.
-C NUM
-c NUM
--context[=NUM]
Output NUM (default 3) lines of copied context.
-d
--minimal
Try hard to find a smaller set of changes.
-E
--ignore-tab-expansion
Ignore changes due to tab expansion.
-e
--ed
Output an ed script.
-F RE
--show-function-line=RE
Show the most recent line matching RE.
--help
Output this help.
--horizon-lines=NUM
Keep NUM lines of the common prefix and suffix.
-i
--ignore-case
Ignore case differences in file contents.
--ignore-file-name-case
Ignore case when comparing file names.
--no-ignore-file-name-case
Consider case when comparing file names.
--label LABEL
Use LABEL instead of file name.
--left-column
Output only the left column of common lines.
-l
--paginate
Pass the output through 'pr' to paginate it.
-N
--new-file
Treat absent files as empty.
--normal
Output a normal diff.
-n
--rcs
Output an RCS format diff.
-p
--show-c-function
Show which C function each change is in.
-q
--brief
Output only whether files differ.
-r
--recursive
Recursively compare any subdirectories found.
--strip-trailing-cr
Strip trailing carriage return on input.
-S FILE
--starting-file=FILE
Start with FILE when comparing directories.
-s
--report-identical-files
Report when two files are the same.
--speed-large-files
Assume large files and many scattered small changes.
--suppress-common-lines
Do not output common lines.
-T
--initial-tab
Make tabs line up by prepending a tab.
-t
--expand-tabs
Expand tabs to spaces in output.
-U NUM
-u NUM
--unified[=NUM]
Output NUM (default 3) lines of unified context.
--unidirectional-new-file
Treat absent first files as empty.
-v
--version
Output version info.
-W NUM
--width=NUM
Output at most NUM (default 130) print columns.
-w
--ignore-all-space
Ignore all white space.
-X FILE
--exclude-from=FILE
Exclude files that match any pattern in FILE.
-x PAT
--exclude=PAT
Exclude files that match PAT.
-y
--side-by-side
Output in two columns.
--from-file=FILE1
Compare FILE1 to all operands. FILE1 can be a directory.
--to-file=FILE2
Compare all operands to FILE2. FILE2 can be a directory.
-D NAME
--ifdef=NAME
Output merged file to show '#ifdef NAME' diffs.
--GTYPE-group-format=GFMT
Similar, but format GTYPE input groups with GFMT.
-I REGEXP
--ignore-matching-lines=REGEXP
Ignore changes whose lines all match REGEXP.
--line-format=LFMT
Similar, but format all input lines with LFMT.
--LTYPE-line-format=LFMT
Similar, but format LTYPE input lines with LFMT.
LTYPE is 'old', 'new', or 'unchanged'.
GTYPE is LTYPE or 'changed'.
GFMT can contain:
%< lines from FILE1
%> lines from FILE2
%= lines common to FILE1 and FILE2
%[-][WIDTH][.[PREC]]{doxX}LETTER
printf-style spec for LETTER
LETTERs are as follows for new group, lower case for old group:
F first line number
L last line number
N number of lines = L-F+1
E F-1
M L+1
LFMT can contain:
%L contents of line
%l contents of line, excluding any trailing newline
%[-][WIDTH][.[PREC]]{doxX}n
printf-style spec for input line number
Either GFMT or LFMT can contain:
%% %
%c'C' The single character C
%c'\OOO' The character with octal code OOO
In the simplest case, diff compares the contents of the two files from-file and to-file. A file name of - stands for text read from standard input. If from-file is a directory and to-file is not, diff compares the file in from-file whose file name is that of to-file, and vice versa. The non-directory file must not be -. If both from-file and to-file are directories, diff compares corresponding files in both directories, in alphabetical order; this comparison is not recursive unless the -r or --recursive option is given. GNU 'diff' can show whether files are different without detailing the differences. End -of-Line markers
Ignore Case
Suppressing Lines Matching a Regular Expression
Summarizing Which Files Differ
Using diff to patch a file
ExamplesReturn 0 if file1.txt = file2.txt and will return 1 if file1.txt ≠ file2.txt:
This example is using command substitution in the form diff <(cmd1) <(cmd2) Note the files have to be sorted first (the order matters) and if the files could contain duplicate values, then the output of sort has to be run through the uniq command to eliminate any duplicate elements. For more on patching files and producing commands that direct the 'ed' text editor to edit a file, run info diff #Oh lord won’t you buy me a Mercedes Benz, my friends all drive Porsches, I must make amends# ~ Janice Joplin Related Linux commandscmp - Compare two files. Copyright © 1999-2026 SS64.com
Some rights reserved |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |