bash: xargs passing variable

bash, linux, variables, xargs

Solution

Take variable `$TEST` out from the quotes:

 TEST=hallo2
 echo "hallo" | xargs sh -c 'echo passed=$1 test='$TEST sh

Problem

How can a global script variable be passed to the command of xargs? I tried it this way: ``` TEST=hallo2 echo "hallo" | xargs sh -c 'echo passed=$1 test=$TEST' sh ``` Output: ``` passed=hallo test= ``` I know I could use the `{}` token but I need to do it this way! I'm using `bash`.

Original source