I tried using diff but it did't work

Are you talking about the unix/gnu diff tool? How did you use it, and in what sense did it not work? Given two files, if they are different, diff will report what the differences are, and will return an exit status of 1 if the files differ, or 0 (="success") if they are identical.

If you don't want to see all the lines that differ, you can use the "cmp" command instead; it gives the same exit status as diff does, but will otherwise be fairly quiet, and will will only read all of its two input files when they happen to be identical (i.e. it stops as soon as it sees a difference). Examples:

cmp file1 file2 && echo same cmp file1 file2 || echo different
But as someone else pointed out, if you have lots of files and you need to compare all possible pairings of files, you'll be better off computing md5 checksums for them (try the "md5sum" command or roll your own in perl with Digest::MD5), then sort by checksum string and look for duplicate checksums.

(Identical checksums is not a guarantee of identical content, different checksums definitely indicate different content. You only need to run cmp on pairs that have the same checksum, to confirm whether they are really identical.)


In reply to Re: quick and safe way to deal with this? by graff
in thread quick and safe way to deal with this? by Anonymous Monk

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.