dotfiles/home/bin/executable_linux-tree-dir

23 lines
488 B
Plaintext
Raw Normal View History

2024-10-20 23:00:34 -07:00
#!/usr/bin/env bash
# Check if the directory is provided
if [ -z "$1" ]; then
echo "Usage: $0 <directory>"
exit 1
fi
# Function to print the tree with SHA256 sums
2024-10-21 09:57:44 -07:00
print_tree_with_md5() {
2024-10-20 23:00:34 -07:00
local dir="$1"
2024-10-21 09:57:44 -07:00
# Use find to recursively list files, and calculate md5sum for each file
2024-10-20 23:00:34 -07:00
find "$dir" -type f | while read -r file; do
2024-10-21 09:57:44 -07:00
md5=$(md5sum "$file" | awk '{print $1}')
echo "$file - $md5"
2024-10-20 23:00:34 -07:00
done
}
# Call the function with the provided directory
2024-10-21 09:57:44 -07:00
print_tree_with_md5 "$1"
2024-10-20 23:00:34 -07:00