At the time of testing, I was hoping to specify the number of threads using parsort but was unable to in a consistent fashion. So, I created a wrapper script named "parallel" that is placed in a path (/usr/local/bin) before (/usr/bin) where "parallel" itself resides.
#!/usr/bin/env bash
# Wrapper script for parallel.
# Whoa!!! GNU Parallel assumes you want to consume all CPU cores.
# Unfortunately, one cannot specify the number of threads for parsort.
CMD="/usr/bin/parallel"
if [[ -z "$PARALLEL_NUM_THREADS" ]]; then
exec "$CMD" "$@"
elif [[ "$#" -eq 1 && "$1" == "--number-of-threads" ]]; then
echo $PARALLEL_NUM_THREADS; exit 0
elif [[ "$1" == "-j" ]]; then
shift; shift; exec "$CMD" -j $PARALLEL_NUM_THREADS "$@"
else
exec "$CMD" -j $PARALLEL_NUM_THREADS "$@"
fi
The environment variable prevents parsort (/usr/bin/parallel, behind the scene) from going semi-wild on a big machine with many CPU cores.
export PARALLEL_NUM_THREADS=12
LC_ALL=C parsort -k1 big{1,2,3}.txt | ./tally-count | LC_ALL=C parsort
+ -k2nr >out.txt
The GNU Parallel "parsort" / "tally-count" combination may be useful for Chuma in the originating Long list is long thread. Chuma wrote, "the files are pretty large (up to a couple hundred MB), there are quite a few of them (2064)."