'different behavior of parallel when input is from STDIN

I am using the GNU parallel tool. I have an input file in.txt the looks like this:

export MY_ENV=$1 && echo hi: $MY_ENV
export MY_ENV=$1 && echo hi: $MY_ENV
export MY_ENV=$1 && echo hi: $MY_ENV
export MY_ENV=$1 && echo hi: $MY_ENV
export MY_ENV=$1 && echo hi: $MY_ENV
export MY_ENV=$1 && echo hi: $MY_ENV

I use this command (case 1) to invoke parallel:

parallel -j 4 -a in.txt  --link ::: 11 22 33 44

which (as expected) results in this output:

hi: 11
hi: 22
hi: 33
hi: 44
hi: 11
hi: 22

However when i try to send the input via STDIN using the command below (case 2) I get different behavior. In other words this command:

cat in.txt | parallel -j 4  --link ::: 11 22 33 44

results in this error message:

/bin/bash: 11: command not found
/bin/bash: 22: command not found
/bin/bash: 33: command not found
/bin/bash: 44: command not found

Shouldn't the behavior be identical? How can I invoke the parallel program so that when the input is via STDIN I get the same output as in case 1 above?



Solution 1:[1]

cat in.txt | parallel -j 4 -a - --link ::: 11 22 33 44

or

cat in.txt | parallel -j 4 --link :::: - ::: 11 22 33 44

or

cat in.txt | parallel -j 4 :::: - :::+ 11 22 33 44

See details on https://doi.org/10.5281/zenodo.1146014 (section 4.2).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1