2016-02-22 20:29:35 -05:00
|
|
|
# cmp
|
|
|
|
|
2021-03-31 12:29:51 +02:00
|
|
|
> Compare two files byte by byte.
|
|
|
|
> More information: <https://www.gnu.org/software/diffutils/manual/html_node/Invoking-cmp.html>.
|
2016-02-22 20:29:35 -05:00
|
|
|
|
2022-07-30 09:05:02 -03:00
|
|
|
- Output char and line number of the first difference between two files:
|
2016-02-22 20:29:35 -05:00
|
|
|
|
2021-03-31 12:29:51 +02:00
|
|
|
`cmp {{path/to/file1}} {{path/to/file2}}`
|
2016-02-22 20:29:35 -05:00
|
|
|
|
2022-07-30 09:05:02 -03:00
|
|
|
- Output info of the first difference: char, line number, bytes, and values:
|
2016-02-22 20:29:35 -05:00
|
|
|
|
2025-03-12 21:05:58 +02:00
|
|
|
`cmp {{[-b|--print-bytes]}} {{path/to/file1}} {{path/to/file2}}`
|
2022-07-30 09:05:02 -03:00
|
|
|
|
|
|
|
- Output the byte numbers and values of every difference:
|
|
|
|
|
2025-03-12 21:05:58 +02:00
|
|
|
`cmp {{[-v|--verbose]}} {{path/to/file1}} {{path/to/file2}}`
|
2022-07-30 09:05:02 -03:00
|
|
|
|
|
|
|
- Compare files but output nothing, yield only the exit status:
|
|
|
|
|
2025-03-12 21:05:58 +02:00
|
|
|
`cmp {{[-s|--quiet]}} {{path/to/file1}} {{path/to/file2}}`
|