commands
diff — compare text files
Reports differences. -u selects unified format. Exit 0 identical, 1 different, 2 trouble. Read-only for regular file comparison; output is not itself an applied change. Example assumes a fresh search-transform lab fixture.
Formal Syntax & Structure
linux syntaxlinux
diff [OPTION]... FILE1 FILE2Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| -u | option | unified format |
| FILE1 | operand | old input |
| FILE2 | operand | new input |
Return Value
exit status and output
Reports differences. -u selects unified format. Exit 0 identical, 1 different, 2 trouble. Read-only for regular file comparison; output is not itself an applied change.
Working Example
Example Snippetlinux
rc=0diff -u --label old.txt --label new.txt old.txt new.txt || rc=$?printf "status=%s\n" "$rc"test "$rc" -eq 1