Name

cmp — stdin  stdout  - file  -- opt  --help  --version

Synopsis

cmp [options] file1 file2 [offset1 [offset2]]

The cmp command compares two files. If their contents are the same, cmp reports nothing; otherwise, it lists the location of the first difference:

$ cmp myfile yourfile
myfile yourfile differ: char 494, line 17

By default, cmp does not tell you what the difference is, only where it is. It also is perfectly suitable for comparing binary files, as opposed to diff, which operates best on text files.

Normally, cmp starts its comparison at the beginning of each file, but it will start elsewhere if you provide offsets:

$ cmp myfile yourfile 10 20

This begins the comparison at the tenth character of myfile and the twentieth of yourfile.

Useful options

-l

Long output: print all differences, byte by byte:

$ cmp -l myfile yourfile
494 164 172

This means at offset 494 (in decimal), myfile has “t” (octal 164) but yourfile has “z” (octal 172).

-s

Silent output: don’t print anything, just exit with an appropriate return code; 0 if the files match, 1 if they don’t. (Or other codes if the comparison fails for some reason.)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.230.107