md5
Matt Kosht
matt.kosht at gmail.com
Wed Mar 30 10:03:38 PST 2005
On Wed, 30 Mar 2005 17:55:11 +0200, Mario Hoerich <lists at 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!
More information about the freebsd-questions
mailing list