Skip to content

Instantly share code, notes, and snippets.

@cchulo
Created March 27, 2025 23:36
Show Gist options
  • Save cchulo/fb43bd85f46e8024613a36b832ca4587 to your computer and use it in GitHub Desktop.
Save cchulo/fb43bd85f46e8024613a36b832ca4587 to your computer and use it in GitHub Desktop.
file for getting checksums of an entire directory. Usage: "./checksum.sh /path/to/directory /path/to/file/report"
#!/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