Create sha.sh
This commit is contained in:
parent
bc45615b9d
commit
cd048610de
1 changed files with 15 additions and 0 deletions
15
sha.sh
Normal file
15
sha.sh
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
# Creates a .sha256 file with the same subfolders and each file (so creates a directory tree identical to the original.
|
||||
SRC_DIR="/data"
|
||||
DATE=$(date +%Y%m%d_%H%M%S)
|
||||
|
||||
find "$SRC_DIR" -type f | while read -r file; do
|
||||
# Get the directory and filename relative to SRC_DIR
|
||||
rel_dir=$(dirname "${file#$SRC_DIR/}")
|
||||
filename=$(basename "$file")
|
||||
# Create a log directory for this file
|
||||
log_dir="/tmp/$rel_dir/$filename"
|
||||
mkdir -p "$log_dir"
|
||||
# Generate sha256 and save to $DATE.sha256 inside the log directory
|
||||
sha256sum "$file" > "$log_dir/$DATE.sha256"
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue