for i,j in file1,md51 \
file2,md52 \
file3,md53
do
compare(md5sum file $i, $j)
done
Thanks
for pair in file1,md51 \
file2,md52 \
file3,md53
do
i=${pair%,*}
j=${pair#*,}
compare(md5sum file $i, $j
done
Andrew
for var in file1,md51 \
file2,md52 \
file3,md53
do
IFS=','; set -f; set x $var; shift
compare(md5sum file "$1", "$2")
done
Here's a code frame...
while read -r md5 f
do
set -- $( md5sum "$f" )
case $1 in
$md5)
printf "Match: md5('%s') is '%s'\n" \
"$f" "$md5" ;;
*) printf "Mismatch: md5('%s') is '%s' but expected '%s'\n" \
"$f" "$md5" "$1" ;;
esac
done
And depending how you want to provide the data pairs...
1) a process generates the md5sum/file pairs
md5sum *.txt *.pdf |
while
# while loop as above
done
2) reading the md5sum/file pairs list from a file
while
# while loop as above
done < file_with_pairs
3) hard coded md5sum/file pairs within the script
while
# while loop as above
done << EOT
a8d67af107b327e1e47795b52762ad18 hello_world.c
190932301eefaae68607941f33ac474c hi_there.txt
EOT
(The usual caveats apply.)
Janis
>
> Thanks