1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 23:44:58 +00:00
serenity/Base/usr/share/man/man1/diff.md
Shannon Booth dfcd5ffaba Base: Update diff(1) man page to latest set of options
Describe how to use the two new context and unified format options in
the diff utility. Also change the example comparison of two files so
they contain more lines as that is much more interesting (and useful).
2023-07-05 10:26:48 +01:00

898 B

Name

diff - compare files line by line

Synopsis

$ diff [options...] [files...]

Description

Compare files line by line.

Arguments

  • files: files to compare ex: file1 file2

Options

  • -u, -U <context>, --unified <context>: Write diff in unified format with <unified> number of surrounding context lines (default 3).
  • -c, -C <context>, --context <context>: Write diff in context format with <context> number of surrounding context lines (default 3).

Examples

First we create two files to compare:

$ printf '1\n2\n3\n' > file1
$ printf '1\nb\n3\n' > file2

Here's how to view differences between the two files in normal format:

$ diff file1 file2
2c2
< 2
---
> b

Here's how to view differences between the two files in unified format:

$ diff -u file1 file2
--- file1
+++ file2
@@ -1,3 +1,3 @@
 1
-2
+b
 3