Edit: I had no idea that awk was so fast, and I suspect that only parallelization would beat it. but I agree with the others that the main bottleneck is the `sort | uniq` for results1.txt
# https://stackoverflow.com/a/27986512 # count word occurrences
# https://unix.stackexchange.com/a/205854 # trim surrounding whitespace
# https://linuxhint.com/awk_trim_whitespace/ # trim leading or trailing whitespace
time cat kjvbible_x100.txt | tr "[:upper:] " "[:lower:]\n" | sort --buffer-size=50M | uniq -c | sort -hr > results1.txt
real 0m13.852s
user 0m13.836s
sys 0m0.229s
time cat kjvbible_x100.txt | tr "[:upper:] " "[:lower:]\n" | awk '{count[$1]++} END {for (word in count) print count[word], word}' | sort -hr > results2.txt
real 0m1.425s
user 0m2.243s
sys 0m0.061s
diff results1.txt results2.txt
109,39133c109,39133
# many whitespace differences due to how `uniq -c` left-pads first column with space
diff <(cat results1.txt | awk '{$1=$1};1') <(cat results2.txt | awk '{$1=$1};1')
# bash-only due to <() inline file, no differences after trimming surrounding whitespace
cat results1.txt | awk '{ sub(/^[ \t]+/, ""); print }' | diff - results2.txt
# sh-compatible, no differences after trimming leading whitespace of results1.txt
# 13.836 / 2.243 = ~6x speedup with awk