Reputation: 1360
Consider the following file saved as commands.txt
ls \
&& pwd
ls \
&& pwd
Now,
bash commands.txt
works as expected to give
LICENSE
/home/username/utilities
LICENSE
/home/username/utilities
but
parallel < commands.txt
gives the error
/bin/bash: -c: line 0: syntax error near unexpected token `&&'
/bin/bash: -c: line 0: `&& pwd'
ls: cannot access '\': No such file or directory
/bin/bash: -c: line 0: syntax error near unexpected token `&&'
/bin/bash: -c: line 0: `&& pwd
Why do multiple lines with the same command separated by \
not seem to work with parralel
as such?
Upvotes: 2
Views: 229
Reputation: 33685
If your input has \n\n
after each group (and only there), you can do:
cat commands.txt | parallel -d '\n\n'
Upvotes: 0
Reputation: 140970
Why do multiple lines with the same command separated by \ not seem to work with parralel as such?
Because parallel
does not parse \
and executes a separate shell for each line.
Upvotes: 1