5

In the terminal it's easy to find the md5sum of a single file, but how about for an entire directory? And would the same apply to sha256sum?

muru
  • 207,228
J. Doe
  • 93

1 Answers1

5

This little script will make sha512sums of a folder and all its subfolders and save it to a file called sha512checksums:

#!/bin/bash
rm -f sha512checksums
find -type f ! -iname "sha512checksums" -exec sha512sum "{}" + > sha512checksums

And this following scrip lets you check the sums based on the before created file:

#!/bin/bash
rm -f sha512errors
sha512sum -c sha512checksums 2> sha512errors 1>/dev/null
if [ -s sha512errors ]
then
  echo The following errors where found while checking:
  more sha512errors
  rm -f sha512errors
else
  echo All files are ok.
  rm -f sha512errors
fi

Same will work as well for every other sum making algorithm, you only would have to alter the scripts.

Videonauth
  • 33,815