The cmp
command is used to compare the two files byte by byte.
Example:
cmp file1.txt file2.txt
Syntax:
cmp [option] File1 File2
Perform a simple comparison of the two files to check out if they differ from each other or not.
Example:
cmp File1 File2
Compare two files after skipping a certain number of bytes
Example:
cmp -i 2 list.txt list2.txt
Here “INT” represents the number of bytes to be skipped
Example:
cmp -b list.txt list1.txt
Example:
cmp -l list.txt list1.txt
Example:
cmp -n 10 list.txt list2.txt
Short Flag | Long Flag | Description |
---|---|---|
-b |
--print-bytes |
print differing bytes |
-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 |
v |
--version |
output version information and exit |
--help |
Display this help and exit |