From 3818cb7cc4e5f14ddc1eb86d3941fca301f53ba3 Mon Sep 17 00:00:00 2001 From: Tyler Starr Date: Sun, 20 Oct 2024 23:00:34 -0700 Subject: [PATCH] add tree script --- home/bin/executable_linux-tree-dir | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 home/bin/executable_linux-tree-dir diff --git a/home/bin/executable_linux-tree-dir b/home/bin/executable_linux-tree-dir new file mode 100644 index 00000000..627b971c --- /dev/null +++ b/home/bin/executable_linux-tree-dir @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Check if the directory is provided +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +# Function to print the tree with SHA256 sums +print_tree_with_sha256() { + local dir="$1" + + # Use find to recursively list files, and calculate sha256sum for each file + find "$dir" -type f | while read -r file; do + sha256=$(sha256sum "$file" | awk '{print $1}') + echo "$file - $sha256" + done +} + +# Call the function with the provided directory +print_tree_with_sha256 "$1" +