terminal.cab

All commands

diff

Topic: Text

Program: diff

Compares two files line by line.

Package: diff

Usage

diff [OPTION]... FILE1 FILE2

Description

Compare two files line by line and show what to change in FILE1 to get FILE2. Lines starting with < are only in FILE1, lines with > only in FILE2. A FILE can be a directory, then diff compares the file with the same name inside it, or with -r all files below it. Exit status 0: same, 1: different, 2: trouble.

Options in the simulator

44 more options of the real program, not in the simulator yet
  • -e, --ed not in the simulator yet

    On a real system diff then writes commands for the ed editor.

  • -n, --rcs not in the simulator yet

    On a real system diff then shows the changes in RCS format.

  • -y, --side-by-side not in the simulator yet

    On a real system diff then shows both files side by side in two columns.

  • -W, --width needs a value not in the simulator yet

    On a real system it sets the width of the two columns of -y.

  • --left-column not in the simulator yet

    On a real system with -y diff then shows equal lines only on the left.

  • --suppress-common-lines not in the simulator yet

    On a real system with -y diff then leaves out equal lines.

  • -p, --show-c-function not in the simulator yet

    On a real system diff then names the C function a change is in.

  • -F, --show-function-line needs a value not in the simulator yet

    On a real system diff then names the last line before a change that matches the pattern.

  • --label needs a value not in the simulator yet

    On a real system LABEL then replaces the file name and time in the header of -u and -c.

  • -t, --expand-tabs not in the simulator yet

    On a real system diff then replaces tabs in its output with spaces.

  • -T, --initial-tab not in the simulator yet

    On a real system diff then puts a tab before the text of each line.

  • --tabsize needs a value not in the simulator yet

    On a real system it sets how far a tab reaches.

  • --suppress-blank-empty not in the simulator yet

    On a real system diff then writes no space before empty lines.

  • -l, --paginate not in the simulator yet

    On a real system diff then splits its output into pages with pr.

  • --no-dereference not in the simulator yet

    On a real system diff then compares symbolic links themselves, not their targets.

  • -N, --new-file not in the simulator yet

    On a real system a missing file then counts as empty.

  • --unidirectional-new-file not in the simulator yet

    On a real system a missing first file then counts as empty.

  • --ignore-file-name-case not in the simulator yet

    On a real system diff then ignores upper and lower case in names inside directories.

  • --no-ignore-file-name-case not in the simulator yet

    On a real system diff pays attention to upper and lower case in names (it does anyway).

  • -x, --exclude needs a value not in the simulator yet

    On a real system diff then skips files in directories whose name matches the pattern.

  • -X, --exclude-from needs a value not in the simulator yet

    On a real system diff then reads the patterns for -x from a file.

  • -S, --starting-file needs a value not in the simulator yet

    On a real system diff then starts at this file inside directories.

  • --from-file needs a value not in the simulator yet

    On a real system diff then compares this file with every operand.

  • --to-file needs a value not in the simulator yet

    On a real system diff then compares every operand with this file.

  • -E, --ignore-tab-expansion not in the simulator yet

    On a real system it then does not matter whether white space is tabs or spaces.

  • -Z, --ignore-trailing-space not in the simulator yet

    On a real system white space at the end of a line then does not count.

  • -B, --ignore-blank-lines not in the simulator yet

    On a real system added or removed empty lines then do not count.

  • -I, --ignore-matching-lines needs a value not in the simulator yet

    On a real system changes whose lines all match the pattern then do not count.

  • --strip-trailing-cr not in the simulator yet

    On a real system diff then removes a carriage return at the end of each line (files from Windows).

  • -D, --ifdef needs a value not in the simulator yet

    On a real system diff then writes both files as one, with #ifdef around the differences.

  • --old-group-format needs a value not in the simulator yet

    On a real system it sets the format for groups of lines with -D.

  • --new-group-format needs a value not in the simulator yet

    On a real system it sets the format for groups of lines with -D.

  • --unchanged-group-format needs a value not in the simulator yet

    On a real system it sets the format for groups of lines with -D.

  • --changed-group-format needs a value not in the simulator yet

    On a real system it sets the format for groups of lines with -D.

  • --line-format needs a value not in the simulator yet

    On a real system it sets the format of each line with -D.

  • --old-line-format needs a value not in the simulator yet

    On a real system it sets the format of one kind of lines with -D.

  • --new-line-format needs a value not in the simulator yet

    On a real system it sets the format of one kind of lines with -D.

  • --unchanged-line-format needs a value not in the simulator yet

    On a real system it sets the format of one kind of lines with -D.

  • -d, --minimal not in the simulator yet

    On a real system diff then searches longer for the smallest number of changes.

  • --horizon-lines needs a value not in the simulator yet

    On a real system it sets how many equal lines at the start and end diff looks at, too.

  • --speed-large-files not in the simulator yet

    On a real system diff then works faster but less exactly on large files.

  • --color value optional not in the simulator yet

    On a real system diff then colors its output.

  • --palette needs a value not in the simulator yet

    On a real system it sets the colors for --color.

  • -v, --version not in the simulator yet

    On a real system diff then shows its version.

Examples

From the lesson Finding lines, finding differences
diff -u conf/app.conf.bak conf/app.conf
--- conf/app.conf.bak	2026-10-16 17:00:00.000000000 +0000
+++ conf/app.conf	2026-10-17 08:00:00.000000000 +0000
@@ -1,4 +1,4 @@
 port = 8080
-workers = 2
-log_level = info
+workers = 4
+log_level = debug
 timeout = 30

Try it in the terminal

Where you learn it

Lessons

All commands