Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Mar 2005 13:03:37 -0500
From:      Matt Kosht <matt.kosht@gmail.com>
To:        Mario Hoerich <lists@mhoerich.de>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: md5
Message-ID:  <a87eda320503301003700653f7@mail.gmail.com>
In-Reply-To: <20050330155508.GC3218@Pandora.MHoerich.de>
References:  <a87eda32050329192919ed1f08@mail.gmail.com> <20050330155508.GC3218@Pandora.MHoerich.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 30 Mar 2005 17:55:11 +0200, Mario Hoerich <lists@mhoerich.de> wrote:
> # Matt Kosht:
> > 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?
> 
> 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
> 

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?a87eda320503301003700653f7>