commands
cmp — compare bytes
Compares bytes. -s suppresses normal output. Status 0 identical, 1 different, 2 trouble. Does not modify inputs. Example assumes a fresh search-transform lab fixture.
Formal Syntax & Structure
linux syntaxlinux
cmp [OPTION]... FILE1 FILE2Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| -s | option | quiet comparison |
| FILE1 | operand | first input |
| FILE2 | operand | second input |
Return Value
exit status and output
Compares bytes. -s suppresses normal output. Status 0 identical, 1 different, 2 trouble. Does not modify inputs.
Working Example
Example Snippetlinux
rc=0cmp -s old.txt old.txt || rc=$?printf "status=%s\n" "$rc"test "$rc" -eq 0