cmp's Examples

this command is used to compare file byte by byte and helps to find out whether the two files are identical or not

$ cmp file1.txt file2.txt

compare two files

$ cmp pavani.txt number.txt

output shows the bte numbers and nyte value for all difeering bytes.

 

$cmp -l file.txt file1.txt

output shows the bte numbers and nyte value for all difeering bytes.

 

$cmp -l file.txt file1.txt

skips fitst 3 nnumber of byte in both the files

$cmp -i 3 file.txt file1.txt

ignore the given number of bytes from both the files

$ cmp -i 15:12 file.txt file1.txt

compare 2 files without using -i (-ignore initial)

$cmp pavani.txt mohit.txt 3

-l shows all differing bytes. and compares only uoto 120 bytes in two files

$ cmp -l -n 120 pavani.txt mohit.txt

hide the output displayed

we canuse --quiet or --silent

$ cmp -s file.txt file1.txt

displays versiion

$cmp -v

displays the differing btes 

$cmp --print bytes file.txt file1.txt

DevOpsSchool
Typically replies within an hour

DevOpsSchool
Hi there 👋

How can I help you?
×
Chat with Us