4

I want to assign a variable in the command that I pass to parallel:

parallel "my_variable={}_33; echo $my_variable" ::: a b c

The output should be:

# a_33
# b_33
# c_33

Of course, this is just a toy example. In the real example I want to do other things with that variable.

1 Answer 1

13

You are so close to solving it yourself. You just forgot that there is a difference between " and ':

parallel 'my_variable={}_33; echo $my_variable' ::: a b c

If you are doing advanced stuff, remember that you can use bash functions:

doit() {
   echo Doing it for $1
   sleep 2
   echo Done with $1
}
export -f doit
parallel doit ::: 1 2 3
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.