Recently, I wanted to get the MD5sums of all of the files in a directory and create a hash sum file for each. This was achieved using the following Bash script.
-
#!/bin sh
-
-
# Directory that contains the files to be hashed
-
YOUR_DIR="/home/username/yourDir"
-
-
# Get a list of files in a directory without the .md5 extension
-
# Note the ticks
-
LIST=`find . -name "*.txt" -a ! -name '.md5'`
-
-
# For each file in the list, generate an MD5sum and
-
# the place the sum inside of a file of the same name, but with
-
# the extension.md5
-
for FILE in $LIST;
-
do
-
md5sum $FILE > FILE.md5
-
done
-
-
exit 0
Add new comment