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;
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;
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`
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`
done;
if [[ $totalSize -le 0 ]]; then die "FATAL:Total size is zero."; fi;
declare -g randPoint
randPoint="$(shuf -n1 -i0-$((totalSize-1)); )";
done;
if [[ $totalSize -le 0 ]]; then die "FATAL:Total size is zero."; fi;
declare -g randPoint
randPoint="$(shuf -n1 -i0-$((totalSize-1)); )";
selCount="$(( selEnd - selStart + 1 ))"; # number of bytes within selection
# Output context
file="$(cut -f2- <<< "${fileSizeList[i]}"; )";
selCount="$(( selEnd - selStart + 1 ))"; # number of bytes within selection
# Output context
file="$(cut -f2- <<< "${fileSizeList[i]}"; )";
tail --bytes=+$((selStart+1)) -- "$file" | head --bytes=$((selCount));
printf "\n";
return 0;
fi;
psum=$sum; # store previous sum
done;
tail --bytes=+$((selStart+1)) -- "$file" | head --bytes=$((selCount));
printf "\n";
return 0;
fi;
psum=$sum; # store previous sum
done;