[clug] Two (perhaps simple) shell questions.

Mark Triggs mark at dishevelled.net
Mon Aug 17 19:39:55 MDT 2009


Andrew Janke <a.janke at gmail.com> writes:

> 2) Suppose I am doing this:
>
> for i in `ls *.mnc`;
> do
>    <program> $i $i.out
> done
>
> In this case <program> is not dependant on any of the other results
> and I often have a large number of them to do. I also happen to have a
> machine with 8 CPU's. So is there a simple C/L function/program/thing
> that will allow me to do this:
>
> for i in `ls *.mnc`;
> do
>    do8ofthisatonce <program> $i $i.out
> done

xargs will do this for you.  Something like:

  ls *.mnc | xargs -I'{}' -P 8 program {} {}.out

Cheers,

Mark

-- 
Mark Triggs
<mark at dishevelled.net>


More information about the linux mailing list