Professional Web Applications Themes

md5 - FreeBSD

Is there a simple way to compare the md5 checksum of a file, to a file that contains possibly more than one md5 checksum entry in it? Kind of like mdsum -c does?...

  1. #1

    Default md5

    Is there a simple way to compare the md5 checksum of a file, to a file
    that contains possibly more than one md5 checksum entry in it? Kind
    of like mdsum -c does?
    Matt Guest

  2. #2

    Default Re: md5

    Matt Kosht <com> writes:
     

    I've never heard of mdsum, but try mtree(8).
    Lowell Guest

  3. #3

    Default Re: md5

    Compare md5 sums:
    $ md5 file1 file2 file3 > checksum.md5
    $ md5 file1 file2 file3 | diff checksum.md5 -

    On Tue, Mar 29, 2005 at 10:29:39PM -0500, Matt Kosht wrote: 

    --
    You can get a lot her with a kind word and a gun
    than with a kind word alone.
    -- Al Capone
    Al Guest

  4. #4

    Default Re: md5

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    On 2005-03-30, Lowell Gilbert scribbled these
    curious markings: 
    >
    > I've never heard of mdsum, but try mtree(8).[/ref]

    Matt is (modulo a typo) referring to the GNU tool md5sum, which is
    oh-so-conveniently named differently than the FreeBSD utility (which
    causes programs that call it, like mplayer modulo the patch that I sent
    in, to fail with "md5sum: not found" errors).

    To answer Matt's original question, I've found that something like this
    works well. This assumes that CHECKSUM contains the actual checksum of
    the file, and only the checksum of that file.

    md5 FILE > mine
    cmp mine CHECKSUM

    Not as short as the GNU version, but still mostly functional. Though,
    now that I write this, I remember having written a Perl program that
    checks SFV sums against a given .sfv file. The principle is more or less
    the same for checking MD5 sums, or $FOO sums, plus a bit of processing.
    I'll see if I can't modify that program to do the sort of thing that
    matt wants.

    Best Regards,
    Christopher Nehren
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.0 (FreeBSD)

    iD8DBQFCSjllk/lo7zvzJioRAjwYAJ99c7VbvBefbqW2XUHeoD759YxiGQCgs3Z/
    +pzROFVhJ3r0dRiwM3sFrpo=
    =R79C
    -----END PGP SIGNATURE-----

    --
    I abhor a system designed for the "user", if that word is a coded
    pejorative meaning "stupid and unsophisticated". -- Ken Thompson
    If you ask the wrong questions, you get answers like "42" and "God".
    Unix is user friendly. However, it isn't idiot friendly.

    Christopher Guest

  5. #5

    Default Re: md5

    # Matt Kosht: 

    Perfect job for a shellscript. :)

    #!/bin/sh

    if [ -z "$2" ]; then
    echo "Usage: `basename $0` <file> <file with sums>" 1>&2
    exit
    fi

    sum=`md5 "$1" | sed 's-^MD5 [^=]*= --'`
    cnt=`grep -c "$sum" "$2"`


    if [ $cnt -eq 0 ]; then
    echo "No match."
    else
    echo "Match."
    fi


    HTH
    Mario
    Mario Guest

  6. #6

    Default Re: md5

    On Wed, 30 Mar 2005 17:55:11 +0200, Mario Hoerich <de> wrote: 
    >
    > Perfect job for a shellscript. :)
    >
    > #!/bin/sh
    >
    > if [ -z "$2" ]; then
    > echo "Usage: `basename $0` <file> <file with sums>" 1>&2
    > exit
    > fi
    >
    > sum=`md5 "$1" | sed 's-^MD5 [^=]*= --'`
    > cnt=`grep -c "$sum" "$2"`
    >
    > if [ $cnt -eq 0 ]; then
    > echo "No match."
    > else
    > echo "Match."
    > fi
    >
    > HTH
    > Mario
    >[/ref]

    Most excellent and appreciated. Works like a champ. Thanks Mario!
    Matt Guest

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139