Skip to content

Instantly share code, notes, and snippets.

@pca2
Created April 18, 2016 15:53
Show Gist options
  • Save pca2/d47cc9bc015c63d40f066b253d08d76c to your computer and use it in GitHub Desktop.
Save pca2/d47cc9bc015c63d40f066b253d08d76c to your computer and use it in GitHub Desktop.
Check the md5sums of two files
#!/bin/bash
check_md5sum(){
sums=$(md5sum $1 $2)
file_1=$(echo $sums | awk '{print $2}')
file_2=$(echo $sums | awk '{print $4}')
checksum_1=$(echo $sums | awk '{print $1}')
checksum_2=$(echo $sums | awk '{print $3}')
if [[ "$checksum_1" == "$checksum_2" ]]; then
echo "OK: $file_1 and $file_2 md5 Checksums Match"
echo $checksum_1 $file_1
echo $checksum_2 $file_2
else
echo "ERROR: md5 checksums Mismatch"
echo $checksum_1 $file_1
echo $checksum_2 $file_2
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment