BSD
Jump to navigation
Jump to search
md5sum
#!/bin/bash # BSD Wrapper for md5 # Kenneth Burgener <kenneth@oeey.com> (2013) check=false checkfile= while getopts "c:" Option do case $Option in c ) checkfile=$OPTARG check=true #echo "check file: $checkfile" ;; * ) echo "Unimplemented option chosen." ;; esac done shift $(($OPTIND - 1)) if $check ; then RC=0 #echo "checking $checkfile..." while read line ; do csum=`echo $line | awk '{print $1}'` cfile=`echo $line | awk '{print $2}'` sum=`md5 -q $cfile` #sum=`echo $sum | awk '{print $1}'` if [ "$csum" == "$sum" ] ; then echo "$cfile: OK" else echo "$cfile: FAILED" RC=1 fi done < $checkfile exit $RC else while true ; do if [ "$1" == "" ] ; then exit fi checkfile=$1 #echo "check: $checkfile" #echo "calcing..." sum=`md5 -q "$checkfile"` echo "$sum $checkfile" shift done fi