Compare two files byte by byte using cmp file comparison utility.

Compare the contents of the two files.

$ cmp fileA fileB
fileA fileB differ: char 590, line 12
$ cmp file1 file2
cmp: EOF on file1 after byte 950009856, in line 3903549

Compare the first 1 MiB.

$ cmp --bytes 1MiB fileA fileB
fileA fileB differ: char 590, line 12

Compare the last 1 MiB.

$ cmp --ignore-initial $(expr $(stat --format=%s file3) - $(expr 1024 \* 1024)) file3 file4
file3 file4 differ: char 1048574, line 17745

Suppress output and use only exit code to indicate change.

$ LC_ALL=C cmp --silent fileA fileA
$ echo $?
$ LC_ALL=C cmp --silent fileA fileB
$ echo $?
1
$ LC_ALL=C cmp --silent file1 fileX
$ echo $?
2

Exit code 0 will indicate that files are identical, exit code 1 that files are different, and exit code 2 that there was some kind of error like an inaccessible file.