5

The command parallel echo {} ::: A B C executed from the command line return the correct result, while when invoked within a bash script return the error:

This is the script:

#script.bash
#!/usr/bin/env bash

parallel echo {} ::: A B C

This is the output:

bash script.bash
/bin/bash: {}: command not found
/bin/bash: ::: command not found
/bin/bash: A: command not found
/bin/bash: B: command not found
/bin/bash: C: command not found

Any idea why and how to correctly call GNU parallel within a bash script?

2
  • Add the script you are running to the question. Commented Jan 13, 2014 at 11:57
  • Edited with script, really basic as you can see. Commented Jan 13, 2014 at 12:01

1 Answer 1

6

Apparently the --tollef switch (that does not support the ::: syntax) gets enabled when you run it from a script.

You can fix it either by enabling the --gnu switch as with

parallel --gnu echo {} ::: A B C
Sign up to request clarification or add additional context in comments.

9 Comments

For example: parallel echo {} $JOBID ::: $(ls), would produce 1,2,3,4. Similar to LSB_JOBINDEX on LSF
@memecs No I haven't seen anything like that on gnu parallel. That does not mean that it does not exist though :)
If it exists it's difficult to find... :). Anyway, thanks a lot for you help
See {#} in man. Also walk through the tutorial: gnu.org/software/parallel/parallel_tutorial.html
@user000001 is --tollef enabled even if you've deleted the option from the file /etc/parallel/config or deleted the config file entirely? On my system that doesn't happen (though I was burned by the --tollef flag in the past, before deleting the config file). See also: stackoverflow.com/a/16448888/868718
|

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.