cmp
Quick Reference
Command Name:
cmp
Category:
file management
Platform:
Linux/Unix
Basic Usage:
Common Use Cases
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:
# Compare two files cmp file1.txt file2.txt
Advanced Examples:
# Compare two files but skip the first 10 bytes of each cmp file1.txt file2.txt 10 10
cat file1.txt | cmp - file2.txt