<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Snipplr - noah</title>
<link>http://snipplr.com/users/noah/tags/cksum</link>
<description>Recent snippets posted on Snipplr.com</description>
<language>en-us</language>
<pubDate>Wed, 15 Feb 2012 03:52:15 GMT</pubDate>
<item>
<title>(Perl) comparing the checksums of two files with Perl and cksum</title>
<link>http://snipplr.com/view/16660/comparing-the-checksums-of-two-files-with-perl-and-cksum/</link>
<description><![CDATA[ <p>This one-liner helps to determine if two or more files have the same
checksum.  It works by piping the output from `cksum` to Perl, which
takes note of the first checksum and compares each subsequent file's
checksum to that value.

Assume an example session where we have three identical files and two
that are different
      
    >echo bart > bart
    >cp bart bart1
    >cp bart bart2
    >echo milhouse > mvh
    >echo lisa > lisa
      
two files with the same checksum, produce no output
      
    >cksum bart bart1 | perl -ane '$x ||= $F[0]; warn if $x != $F[0];'
      
if a there is a different checksum, the line numbers printed are the
indexes of those files
      
    >cksum bart bart1 mvh bart2 lisa | perl -ane '$x ||= $F[0]; warn if $x != $F[0];'
    Warning: something's wrong at -e line 1,  line 3.
    Warning: something's wrong at -e line 1,  line 5.</p> ]]></description>
<pubDate>Sun, 05 Jul 2009 21:17:39 GMT</pubDate>
<guid>http://snipplr.com/view/16660/comparing-the-checksums-of-two-files-with-perl-and-cksum/</guid>
</item>
</channel>
</rss>
