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 to3. Classic context diff, cozy little bubble of surrounding lines.-u,-U NUM,--unified[=NUM]โ output NUM lines of unified context, NUM defaults to3. 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 to130.--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 to8.--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 โprwith 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 numberLโ last line numberNโ number of lines =L-F+1EโF-1Mโ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 OOOCโ 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--colormeans--color='auto'.--palette=PALETTEโ the colors to use when--coloris 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:0if inputs are the same,1if different,2if trouble. ๐ญ The2is 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 โญ
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 ๐ซถโจ๐
๐ฆ where this page comes from
- alpine 3.22: diffutils-doc 3.12-r0 ยท GPL-3.0-or-later
- alpine 3.23: diffutils-doc 3.12-r0 ยท GPL-3.0-or-later
- alpine 3.24: diffutils-doc 3.12-r0 ยท GPL-3.0-or-later
- arch rolling: diffutils 3.12-2 ยท GPL-3.0-or-later
- fedora 43: diffutils 3.12-3.fc43 ยท GPL-3.0-or-later
- fedora 44: diffutils 3.12-5.fc44 ยท GPL-3.0-or-later
- nixos 26.05: diffutils 3.12
- nixos 26.05: diffutils-static 3.12
- nixpkgs unstable: diffutils 3.12
- opensuse-leap 16.0: diffutils 3.12-160000.2.2 ยท GFDL-1.2-only AND GPL-3.0-or-later
- opensuse-leap 16.0: diffutils 3.12-160000.2.2 ยท GFDL-1.2-only AND GPL-3.0-or-later
- opensuse-leap 16.0: diffutils 3.12-160000.2.2 ยท GFDL-1.2-only AND GPL-3.0-or-later
- opensuse-leap 16.0: diffutils 3.12-160000.2.2 ยท GFDL-1.2-only AND GPL-3.0-or-later
- ubuntu resolute: diffutils 1:3.12-1 ยท GPL-3.0-or-later
- ubuntu resolute: diffutils 1:3.12-1ubuntu0.1 ยท GPL-3.0-or-later
- ubuntu stonking: diffutils 1:3.12-1ubuntu2 ยท GPL-3.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms