Simple Bash Parallel Tool (env_parallel dies on big env)
A couple of things could be written better, let's go from top to bottom.



It's recommended to double-quote variables when used as paths,
to avoid globbing and word-splitting.
Even if you're certain that $TMP_FILE won't have any troublesome characters, it's a good practice to double-quote anyway:

touch "$TMP_FILE"


Similarly, you should double-quote $prog in $prog 1&gt;$PROG_TMP 2&gt;&amp;1.



You can simplify for arg in "$@"; do loop as for arg; do.



In Bash, instead of prog 1&gt; somewhere 2&gt;&amp;1 you can write prog &amp;&gt; somewhere.



Instead of this:


RESULT_COUNT=$(wc -l ${TMP_FILE} | awk '{ print $1 }')



You could write simpler without awk like this:

RESULT_COUNT=$(wc -l &lt; "$TMP_FILE")


The trick is that when wc is used with stdin,
it won't print a file name, only the number.
Although RESULT_COUNT will have some whitespace padding,
if you use it in [ ... ] without double-quoting,
it will behave as expected.

Notice again that I double-quoted $TMP_FILE.



Don't use -eq in [[ ... ]], use == or = instead.



This is pretty ugly:


if [[ $(cat $TMP_FILE) == *"1"* ]]; then



A better way to achieve the same thing is using grep:

if grep -q 1 "$TMP_FILE"; then