parallel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiple complex replacements per command?


From: Jay Hacker
Subject: Re: Multiple complex replacements per command?
Date: Mon, 19 Nov 2012 13:18:55 -0500

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 <ole@tange.dk> wrote:
On Thu, Nov 15, 2012 at 7:21 PM, Jay Hacker <jayqhacker@gmail.com> 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

[Prev in Thread] Current Thread [Next in Thread]