From: Steven Baltakatei Sandoval Date: Tue, 21 Oct 2025 03:43:53 +0000 (+0000) Subject: feat(user/randtxt.sh):v0.0.4:Remove debug lines X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/commitdiff_plain/9f9597301d4bd3929ce145631ea040b269abed69?hp=e0e6397741c0e63627a7c752d9e4803b37093614 feat(user/randtxt.sh):v0.0.4:Remove debug lines --- diff --git a/user/randtxt.sh b/user/randtxt.sh index c809246..cd242a2 100755 --- a/user/randtxt.sh +++ b/user/randtxt.sh @@ -3,6 +3,7 @@ # Usage: randtxt.sh DIR # Version 0.0.4 # Depends: Bash 5.1.16, GNU findutils 4.8.0, GNU Coreutils 8.32 +# Example: randtxt.sh ~/Calibre\ Library/ SAMPLE=10000; CONTEXT="5000"; # total bytes +1 before and after point within file to print @@ -26,7 +27,6 @@ checkInput() { if [[ $# -gt 1 ]]; then die "FATAL:Too many arguments"; fi; if [[ $# -lt 1 ]]; then die "FATAL:Not enough arguments"; fi; if [[ ! -d "$1" ]]; then die "FATAL:Not a dir:$1"; else return 0; fi; - #yell "DEBUG:checkInput() finished."; # debug }; getFileSizeList() { # Desc: Create list of file sizes and paths @@ -39,26 +39,17 @@ getFileSizeList() { mapfile -d '' -t fileSizeList < <( find -- "$1" -type f -name "*.txt" -printf '%s\t%p\0' | shuf -z -n"$SAMPLE"; ); # Build array by feeding null-delimited lines from `find` to `mapfile` - #declare -p fileSizeList; # debug declare -g totalSize=0; local i size; for i in "${!fileSizeList[@]}"; do - #declare -p i; # debug - #yell "DEBUG:fileSizeList[i]:${fileSizeList[i]}"; # debug size="${fileSizeList[i]%%$'\t'*}"; - #declare -p size; # debug totalSize=$((totalSize + size)); - #declare -p i size totalSize; # debug - #yell "=============="; # debug done; if [[ $totalSize -le 0 ]]; then die "FATAL:Total size is zero."; fi; declare -g randPoint randPoint="$(shuf -n1 -i0-$((totalSize-1)); )"; - #declare -p fileSizeList totalSize randPoint 1>&2; - #yell "DEBUG:fileSizeList element count:${#fileSizeList[@]}"; # debug - #yell "DEBUG:getFileSizeList() finished."; # debug }; getRandText() { # Desc: Print text within fileSizeList around randPoint @@ -89,14 +80,12 @@ getRandText() { # Output context file="$(cut -f2- <<< "${fileSizeList[i]}"; )"; printf "INFO:Sample of:%s\n" "$file"; - #head --bytes=$((selEnd + 1 )) -- "$file" | tail --bytes=+$((selStart + 1)); tail --bytes=+$((selStart+1)) -- "$file" | head --bytes=$((selCount)); printf "\n"; return 0; fi; psum=$sum; # store previous sum done; - #yell "DEBUG:getRandText() finished."; # debug }; export -f checkInput getFileSizeList getRandText;