You are not logged in.
Hi.
In an usual day I do a lot of for loops inside of command line. But I noted that my loops don't use the full power of my dual core processor, they only use one processor.
A lot of the loops I do have independent interactions in the sense that a interaction code don't need the results of another interaction. This is the simplest problem in multiprocessing, I only need to execute N process in parallel.
I'm searching for a one-line solution that I can use in place of a 'for i in *.txt; do echo $i;done'. With one-line I means that can be used as one-line but the implementation can be longer. And can be in any programming language.
For now I'm using the following small python solution (the smallest I could get)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from multiprocessing import Pool
from glob import glob
from subprocess import call
def f(x):
call(['asy', '-f', 'png', '-render=0', x])
pool = Pool(processes=4)
pool.map(f, glob('*.asy'))
But I like something that can be integrated in my "shell life". Anyone know a solution for my problem?
Offline
http://stackoverflow.com/questions/3816 … ash-script
http://www.mail-archive.com/bug-bash@gn … 05820.html
Last edited by karol (2009-11-23 00:30:34)
Offline