#!/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 #### export PARALLEL_NUM_THREADS=12 LC_ALL=C parsort -k1 big{1,2,3}.txt | ./tally-count | LC_ALL=C parsort -k2nr >out.txt