Skip to content

Instantly share code, notes, and snippets.

@cchulo
Created March 27, 2025 23:35
Show Gist options
  • Save cchulo/80c55b8f507f9f4ce1a24e1f262016b9 to your computer and use it in GitHub Desktop.
Save cchulo/80c55b8f507f9f4ce1a24e1f262016b9 to your computer and use it in GitHub Desktop.
file for getting checksums of an entire directory.
#!/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