OnCallReadyStart learning

diff: compare files line by line

diff [OPTION]... FILE1 FILE2

Options you will use

-u, -U N, --unified[=N]
Unified format: --- / +++ headers, @@ -start,count +start,count @@ hunks, N lines of context (default 3). What code review, git and patch use.
-c, -C N, --context[=N]
Context format: *** / --- headers, ! for a changed line, - removed, + added.
-y, --side-by-side
Two columns: | changed, < only on the left, > only on the right.
-W N, --width=N
With -y: at most N columns in all (default 130).
--suppress-common-lines
With -y: do not print the lines that are the same.
-q, --brief
Only say whether the files differ (exit status 1), no details.
-s, --report-identical-files
Say so when two files are the same.
-r, --recursive
Compare two directories, and their subdirectories, file by file. "Only in DIR: NAME" = a file one side does not have.
-N, --new-file
A file missing on one side counts as empty: its whole content shows as added or removed.
-i, --ignore-case
Upper and lower case count as the same.
-w, --ignore-all-space
Ignore all white space when comparing lines.
-b, --ignore-space-change
Ignore changes in the amount of white space (and trailing white space).
-B, --ignore-blank-lines
Ignore changes that only add or remove empty lines.
-a, --text
Compare as text even if a file looks binary (has NUL bytes).
-x PAT, --exclude=PAT
With -r: skip files whose name matches PAT.
--label LABEL
Use LABEL instead of the file name and time in the header (give it twice for both files).
--color[=WHEN]
Colour the output: never (default), always, auto (= only on a terminal; --color alone means auto).

Examples

$ diff -u app.conf.bak app.conf

what changed since the backup, in the review format

$ diff -r overlays/dev overlays/prod

every difference between two directories

$ diff <(sort a.txt) <(sort b.txt)

compare two outputs without temp files

$ diff -u old.conf new.conf > fix.diff

save a patch for patch -p0 < fix.diff

Gotchas

Taught in

Try diff in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.