Add script to generate shasum from folder
This commit is contained in:
		
							
								
								
									
										27
									
								
								dirsha256sum
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										27
									
								
								dirsha256sum
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
if [[ -z $1 ]]; then
 | 
			
		||||
	echo "Usage: $0 <path to folder>"
 | 
			
		||||
	exit -1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [[ ! -d "$1" ]]; then
 | 
			
		||||
	echo "Specified path: $1 is not a directory"
 | 
			
		||||
	exit -2
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
search_dir="$1"
 | 
			
		||||
 | 
			
		||||
filelist=()
 | 
			
		||||
while IFS= read -d $'\0' -r file ; do
 | 
			
		||||
	filelist=("${filelist[@]}" "$file")
 | 
			
		||||
done < <(find "$search_dir" -type f -print0)
 | 
			
		||||
 | 
			
		||||
echo "Found ${#filelist[@]} files"
 | 
			
		||||
 | 
			
		||||
# Calculate shasums over all files
 | 
			
		||||
shasum=`for file in "${filelist[@]}"; do
 | 
			
		||||
	sha256sum "$file"
 | 
			
		||||
done | sha256sum | sed 's/\s-//'`
 | 
			
		||||
 | 
			
		||||
echo "$shasum"
 | 
			
		||||
		Reference in New Issue
	
	Block a user