DIFF(1)

โœจ NAME โœจ

okay so bestie, we're doing diff today โ€” yes, the DIFF(1) one, the classic. Grab a snack. ๐Ÿ“

diff โ€” compare files line by line


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

diff [OPTION]... FILES

๐ŸŒธ DESCRIPTION ๐ŸŒธ

Compare FILES line by line. That's the whole plot. Two things walk in, diff tells you every single line where they don't agree. Honestly? Iconic behaviour. ๐Ÿ’…

Quick thing the manual insists on, and it's real: mandatory arguments to long options are mandatory for short options too. So if --exclude=PAT needs a PAT, then -x needs a PAT too. No skipping, no cap.

๐Ÿ’– OPTIONS ๐Ÿ’– (the full menu โ€” we are not skipping a single one)

  • --normal โ€” output a normal diff. This is the default, so it's giving "showed up in my default fit and still ate". โœจ
  • -q, --brief โ€” report only when the files differ. Lowkey the "just tell me yes or no" option.
  • -s, --report-identical-files โ€” opposite energy, and honestly so sweet: report when two files are the same. Give those matching files their flowers. ๐ŸŒธ
  • -c, -C NUM, --context[=NUM] โ€” output NUM lines of copied context, and NUM defaults to 3. Classic context diff, cozy little bubble of surrounding lines.
  • -u, -U NUM, --unified[=NUM] โ€” output NUM lines of unified context, NUM defaults to 3. Yes bestie, this is the format everybody actually uses. Main character energy, fr fr. ๐Ÿ‘‘
  • -e, --ed โ€” output an ed script. Retro. Vintage. Serving 1970s in the best way. ๐ŸŽ€
  • -n, --rcs โ€” output an RCS format diff.
  • -y, --side-by-side โ€” output in two columns. Side by side, like besties. ๐Ÿซถ
  • -W, --width=NUM โ€” output at most NUM print columns, and NUM defaults to 130.
  • --left-column โ€” output only the left column of common lines. Half the table, all the vibe.
  • --suppress-common-lines โ€” do not output common lines. We're only here for the drama. ๐Ÿ’€
  • -p, --show-c-function โ€” show which C function each change is in. C girlies, this one's yours.
  • -F, --show-function-line=RE โ€” show the most recent line matching RE.
  • --label LABEL โ€” use LABEL instead of the file name and timestamp. And yes, it can be repeated. Slay.
  • -t, --expand-tabs โ€” expand tabs to spaces in output.
  • -T, --initial-tab โ€” make tabs line up by prepending a tab.
  • --tabsize=NUM โ€” tab stops every NUM print columns, NUM defaults to 8.
  • --suppress-blank-empty โ€” suppress space or tab before empty output lines.
  • -l, --paginate โ€” pass output through 'pr' to paginate it. (That's literally how the manual writes it โ€” pr with the quotes. Not me being chaotic, promise.)
  • -r, --recursive โ€” recursively compare any subdirectories found. It goes deep. It goes ALL the way down. ๐Ÿ•ณ๏ธ
  • --no-dereference โ€” don't follow symbolic links. We respect the symlink's boundaries.
  • -N, --new-file โ€” treat absent files as empty. Nothing there? Cool. Empty file. Let's go.
  • --unidirectional-new-file โ€” treat absent first files as empty. Note the word first โ€” it's specifically the first one, bestie.
  • --ignore-file-name-case โ€” ignore case when comparing file names.
  • --no-ignore-file-name-case โ€” consider case when comparing file names. (Yes, it's the undo button for the one above. We love a matched pair.)
  • -x, --exclude=PAT โ€” exclude files that match PAT.
  • -X, --exclude-from=FILE โ€” exclude files that match any pattern in FILE.
  • -S, --starting-file=FILE โ€” start with FILE when comparing directories.
  • --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.
  • -i, --ignore-case โ€” ignore case differences in file contents.
  • -E, --ignore-tab-expansion โ€” ignore changes due to tab expansion.
  • -Z, --ignore-trailing-space โ€” ignore white space at line end.
  • -b, --ignore-space-change โ€” ignore changes in the amount of white space.
  • -w, --ignore-all-space โ€” ignore all white space. ALL of it. Gone. Not invited to the party. ๐Ÿ™ˆ
  • -B, --ignore-blank-lines โ€” ignore changes where lines are all blank.
  • -I, --ignore-matching-lines=RE โ€” ignore changes where all lines match RE.
  • -a, --text โ€” treat all files as text. No binary slander in this house.
  • --strip-trailing-cr โ€” strip trailing carriage return on input.
  • -D, --ifdef=NAME โ€” output merged file with '#ifdef NAME' diffs.

๐ŸŒˆ the format options (we ARE going there) ๐ŸŒˆ

  • --GTYPE-group-format=GFMT โ€” format GTYPE input groups with GFMT.
  • --line-format=LFMT โ€” format all input lines with LFMT.
  • --LTYPE-line-format=LFMT โ€” format LTYPE input lines with LFMT.

These format options provide fine-grained control over the output of diff, generalizing -D/--ifdef. So basically: the ifdef thing, except you get to control literally everything. Chef's kiss. ๐Ÿ˜˜

  • LTYPE is 'old', 'new', or 'unchanged'.
  • GTYPE is LTYPE or 'changed'.

GFMT (and only GFMT) may 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
  • %(A=B?T:E) โ€” if A equals B then T else E

LFMT (and only LFMT) may contain:

  • %L โ€” contents of line
  • %l โ€” contents of line, excluding any trailing newline
  • %[-][WIDTH][.[PREC]]{doxX}n โ€” printf-style spec for input line number

Both GFMT and LFMT may contain:

  • %% โ€” %
  • %c'C' โ€” the single character C
  • %c'\OOO' โ€” the character with octal code OOO
  • C โ€” the character C (other characters represent themselves)

๐Ÿ”ฅ and we're back to the regular options ๐Ÿ”ฅ

  • -d, --minimal โ€” try hard to find a smaller set of changes. It's putting in the EFFORT. ๐Ÿ˜ค
  • --horizon-lines=NUM โ€” keep NUM lines of the common prefix and suffix.
  • --speed-large-files โ€” assume large files and many scattered small changes.
  • --color[=WHEN] โ€” color output!! WHEN is 'never', 'always', or 'auto'; a plain --color means --color='auto'.
  • --palette=PALETTE โ€” the colors to use when --color is active; PALETTE is a colon-separated list of terminfo capabilities.
  • --help โ€” display this help and exit. A king who knows how to exit. ๐Ÿ‘‘
  • -v, --version โ€” output version information and exit.

๐ŸŽ€ the FILES rules (read these, bestie) ๐ŸŽ€

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 FILE(s). If a FILE is '-', read standard input.

Exit status, memorize it: 0 if inputs are the same, 1 if different, 2 if trouble. ๐Ÿ˜ญ The 2 is the "something went wrong" one and you WILL see it at 3am.

๐Ÿ’œ AUTHOR ๐Ÿ’œ

Written by Paul Eggert, Mike Haertel, David Hayes, Richard Stallman, and Len Tower. Absolute legends, every single one. ๐Ÿ‘‘


๐Ÿ› REPORTING BUGS ๐Ÿ›

Report bugs to: bug-diffutils@gnu.org

GNU diffutils home page: https://www.gnu.org/software/diffutils/

General help using GNU software: https://www.gnu.org/gethelp/


Copyright ยฉ 2025 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later https://gnu.org/licenses/gpl.html.

This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Not me being dramatic, that's just what it says. No warranty. None. Periodt.

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

wdiff(1), cmp(1), diff3(1), sdiff(1), patch(1)

The full documentation for diff is maintained as a Texinfo manual. If the info and diff programs are properly installed at your site, the command

info diff

should give you access to the complete manual.


and that's the whole page, bestie ๐Ÿ’– this was diffutils 3.12, dated April 2025 โ€” go forth and diff responsibly, mwah ๐Ÿซถโœจ๐ŸŽ€