Created
March 14, 2022 03:06
-
-
Save srkiNZ84/3560d596714250f4b4018fa366c0f293 to your computer and use it in GitHub Desktop.
Generate md5sum on all files and subdirs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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