Here's a bash script that I wrote to calculate the MD5 hash of all files in the specified directory and below. It's quick and dirty, but I've found it useful to compare files in 2 directories to see if anything has changed. I can pipe the results out to a file for each directory and then diff them. OR, even better, you can compare them with md5sum itself by:
cd <dir-to-compare> md5sum -c <file-contatining-sums>
Here's the script:
#!/bin/bash # Script that calculates an MD5 hash for each file in the specified directory # and all directories below that. # # Author: Tom Pierce # Date: 10/31/02
export IFS=$'t\n'
# a quick check to see if any files were given # if none then its better not to do anything than rename some non-existent # files!! if [ "$1" == "" ] then echo "Usage: md5dir " exit 0 fi
# For each file in the specified directory, get the md5 for file in $(find $1 -type f) do md5sum "$file" done
10:34:31 AM
|