Created
March 27, 2025 23:35
-
-
Save cchulo/80c55b8f507f9f4ce1a24e1f262016b9 to your computer and use it in GitHub Desktop.
file for getting checksums of an entire directory.
This file contains hidden or 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
#!/bin/bash | |
# Output file to store the SHA256 checksums | |
output_file="$2" | |
# Empty the output file if it already exists | |
> "$output_file" | |
# Generate a list of all files using 'tree' and process each line | |
tree -afi --noreport "$1" | while IFS= read -r file; do | |
# Check if the path is a regular file | |
if [ -f "$file" ]; then | |
# Compute SHA256 checksum and append to the output file | |
sha256sum "$file" >> "$output_file" | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment