-
-
Save d4z3x/fd96fa19eba3483f6842a937146bcb91 to your computer and use it in GitHub Desktop.
Revisions
-
pmarreck revised this gist
May 12, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ mkdir -p "$dir_name/$file_name" while IFS= read -r line do # Hash the line with sha256 and use it as the file name file_hash=$(echo -n "$line" | cksum | awk '{print $1}') # Write the line to the new file echo "$line" > "$dir_name/$file_name/$file_hash.txt" -
pmarreck revised this gist
May 12, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ # Ensure a file name is provided if [ -z "$1" ] then echo "No file name provided. Usage: ./split_file.bash <filename>" exit 1 fi -
pmarreck created this gist
May 12, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ #!/usr/bin/env bash # Ensure a file name is provided if [ -z "$1" ] then echo "No file name provided. Usage: ./split_file.sh <filename>" exit 1 fi # Extract the directory and base name from the file dir_name=$(dirname "$1") base_name=$(basename "$1") file_name="${base_name%.*}" # Create directory to store the split files mkdir -p "$dir_name/$file_name" # Read the file line by line while IFS= read -r line do # Hash the line with sha256 and use it as the file name file_hash=$(echo -n "$line" | openssl dgst -sha256 | awk '{print $2}') # Write the line to the new file echo "$line" > "$dir_name/$file_name/$file_hash.txt" done < "$1"