Skip to content

Instantly share code, notes, and snippets.

@srkiNZ84
Created March 14, 2022 03:06
Show Gist options
  • Save srkiNZ84/3560d596714250f4b4018fa366c0f293 to your computer and use it in GitHub Desktop.
Save srkiNZ84/3560d596714250f4b4018fa366c0f293 to your computer and use it in GitHub Desktop.
Generate md5sum on all files and subdirs
#!/usr/bin/bash
# Setup our files
mkdir hashtest
echo hello > hashtest/file1.txt
echo foo > hashtest/file2.txt
echo bar > hashtest/file3.txt
mkdir hashtest/subdir
echo baz > hashtest/subdir/file4.txt
echo hello > hashtest/subdir/file5.txt
# Generate hashes for all files
find ./hashtest/ -type f -exec md5sum {} \;
# Save hashes to a file
find ./hashtest/ -type f -exec md5sum {} + > checklist.md5
# Verify the hashes from the file
md5sum -c checklist.md5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment