Another way to compare the contents of two files at the byte level is to hash both of them and compare the hashes. (it's the entire purpose of digest hashes).

$ dd if=/dev/urandom of=file1 bs=1K count=10 10+0 records in 10+0 records out 10240 bytes (10 kB, 10 KiB) copied, 0.000148608 s, 68.9 MB/s $ dd if=/dev/urandom of=file2 bs=1K count=10 10+0 records in 10+0 records out 10240 bytes (10 kB, 10 KiB) copied, 0.000145675 s, 70.3 MB/s $ ls -l total 24 -rw-r--r-- 1 foo foo 10240 Feb 9 17:47 file1 -rw-r--r-- 1 foo foo 10240 Feb 9 17:47 file2 $ sha256sum * 7986a677d3ef9a4f71ba18a5a7bd3a5f9a0c2d16939b4a43cd49fde86cef5a2f file +1 3c946e3212d808dbb7471eecc07e454c459352a6a3e25230288fe5faf08af555 file +2

This shows that despite file1 and file2 having precisely the same size, their contents differ because the SHA256 hashes differ. See sha256sum for more.


🦛


In reply to Re^5: Download from Perl script corrupted for XLSX file. by hippo
in thread Download from Perl script corrupted for XLSX file. by TorontoJim

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.