cmp
Quick Reference
Command Name:
cmp
Category:
file management
Platform:
Linux/Unix
Basic Usage:
Common Use Cases
- 1
File comparison
Compare two files byte by byte for differences
- 2
Data validation
Verify that files are identical or detect differences
- 3
Quality assurance
Ensure file integrity and consistency
- 4
Script automation
Automate file comparison in scripts and workflows
Syntax
cmp [OPTION]... FILE1 [FILE2 [SKIP1 [SKIP2]]]
Options
Option | Description |
---|---|
-b, --print-bytes |
Print differing bytes as ASCII |
-i, --ignore-initial=SKIP |
Skip first SKIP bytes of both inputs |
-i, --ignore-initial=SKIP1:SKIP2 |
Skip first SKIP1 bytes of FILE1 and first SKIP2 bytes of FILE2 |
-l, --verbose |
Output byte numbers and differing byte values |
-n, --bytes=LIMIT |
Compare at most LIMIT bytes |
-s, --quiet, --silent |
Suppress all normal output, only return exit status |
--help |
Display help message and exit |
--version |
Output version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the cmp
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
cmp file1.txt file2.txt
cmp -s file1.txt file2.txt
cmp -l file1.txt file2.txt
cmp --print-bytes file1.txt file2.txt