You're right, those hurt my head.  It's complicated.

I discovered a way to do it with two parallels (haven't thoroughly tested
it):

$ seq 12 | parallel echo "'a {} b {}'" | parallel -tX mycmd
mycmd a\ 1\ b\ 1 a\ 2\ b\ 2 a\ 3\ b\ 3
mycmd a\ 4\ b\ 4 a\ 5\ b\ 5 a\ 6\ b\ 6
mycmd a\ 7\ b\ 7 a\ 8\ b\ 8 a\ 9\ b\ 9
mycmd a\ 10\ b\ 10 a\ 11\ b\ 11 a\ 12\ b\ 12

The first one literally needs to be "echo", the second one is the actual
command you want to run.  (It's ugly, but notice there are "real" spaces
hiding in between the arguments to mycmd.)


On Thu, Nov 15, 2012 at 5:48 PM, Ole Tange <[email protected]> wrote:

> On Thu, Nov 15, 2012 at 7:21 PM, Jay Hacker <[email protected]> wrote:
>
> > I'd like to be able to give as many parameters as will fit on a command
> > line, so I can fork less jobs:
> >
> > $ seq 4 | parallel -??? echo "'a {} b {}'"
> > a 1 b 1 a 2 b 2 a 3 b 3 a 4 b 4
> >
> > I looked into -X, -L, -n, -m, --xargs, and variations, but none of them
> seem
> > to do what I want.  Is there a way to do this with parallel?
>
> The problem boils down to how do you determine what are arguments
> without parsing the line?
>
> What should these give:
>
> seq 4 | parallel -??? echo "'a {} b {}'"\; echo foo
> seq 4 | parallel -??? echo -n "'a {} b {}'"\; echo foo
> seq 4 | parallel -??? echo "'a {} b {}'" -n \; echo foo
> seq 4 | parallel -??? 'echo "a {} b {}"; echo foo'
> seq 4 | parallel -??? echo -n "'a {} b {}'; echo" foo
> seq 4 | parallel -??? echo "'a {} b {}'" -n \; echo foo
>
> Right now I try to adhere to principle of least surprise.
>
> You _can_ do this:
>
> seq 4 | parallel -j1 -X echo a_{}_b_{}
>
>
> /Ole
>

Reply via email to