On Sun, Dec 21, 2008 at 10:52 PM, Sven Hartrumpf
<[email protected]> wrote:
> Hi all.
>
> Is there a way to access the partition number of xargs' arguments on
> the command line?
>
> Example:
> xargs -a argfile -n 10 -P 4 processor-program %I ...
>
> %I should be iterating from 1 (or 0) to (number-of-files-in-argfile +
> 9 / 10).

To be honest it's a little difficult to evaluate your question without
a fuller understanding of your use case.  From what you say so far, it
appears to perhaps be that you want to use %I to use as a hash key
allowing you to select one of several parallel backend services in
some kind of fair manner.  But perhaps that's not what you are really
trying to do.

If however, you are trying to do something like this I would encourage
you to use an auxiliary script to do it.  You could maintain the
sequence number in a file and use advisory locks to arbitrate access
to it, for example.

Thanks,
James.


Reply via email to