<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: Scripting the parallel execution of a tedious task</title>
	<link>http://ask.metafilter.com/52998/Scripting-the-parallel-execution-of-a-tedious-task/</link>
	<description>Comments on Ask MetaFilter post Scripting the parallel execution of a tedious task</description>
	<pubDate>Tue, 12 Dec 2006 12:09:07 -0800</pubDate>
	<lastBuildDate>Tue, 12 Dec 2006 12:09:07 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: Scripting the parallel execution of a tedious task</title>
		<link>http://ask.metafilter.com/52998/Scripting-the-parallel-execution-of-a-tedious-task</link>	
		<description>Calling all shell script gurus! Help me write a command that performs an action on items in a list in parallel (as opposed to sequentially). &lt;br /&gt;&lt;br /&gt; I am trying to write a command that zeroes out the data on any number of attached disks simultanously (or nearly so). I started with the basics and have written the script below that accomplishes the task sequentially. (This is in Mac OS X, bash shell):&lt;br&gt;
&lt;code&gt;&lt;br&gt;
diskutil list | grep /disk | grep -v disk0 | sed &apos;s|/dev/||g&apos; | \&lt;br&gt;
while read DISK; do&lt;br&gt;
diskutil zeroDisk $DISK&lt;br&gt;
done&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
The first line returns a list of attached disks:&lt;br&gt;
disk1&lt;br&gt;
disk2&lt;br&gt;
disk3&lt;br&gt;
etc... all except disk0.&lt;br&gt;
&lt;br&gt;
Nothing I care about resides on any disk but disk0, which is why it&apos;s excluded. The while loop executes the &apos;diskutil zerodisk&apos; command on each item in the list. I can manually start this command on each disk and the computer will happily perform the tasks in parallel. How can I script the parallel execution of this task?</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2006:site.52998</guid>
		<pubDate>Tue, 12 Dec 2006 12:03:01 -0800</pubDate>
		<dc:creator>pmbuko</dc:creator>
		
			<category>mac</category>
		
			<category>unix</category>
		
			<category>scripting</category>
		
			<category>shell</category>
		
			<category>shellscript</category>
		
	</item> <item>
		<title>By: Good Brain</title>
		<link>http://ask.metafilter.com/52998/Scripting-the-parallel-execution-of-a-tedious-task#798985</link>	
		<description>try either &lt;br&gt;
&quot;bg diskutil zeroDisk $DISK&quot;&lt;br&gt;
or&lt;br&gt;
&quot;diskutil zeroDisk $DISK &amp;amp;&quot;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.52998-798985</guid>
		<pubDate>Tue, 12 Dec 2006 12:09:07 -0800</pubDate>
		<dc:creator>Good Brain</dc:creator>
	</item><item>
		<title>By: pmbuko</title>
		<link>http://ask.metafilter.com/52998/Scripting-the-parallel-execution-of-a-tedious-task#798996</link>	
		<description>the &amp;amp; gives me an error. I should have mentioned that. It works fine outside a script, though.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.52998-798996</guid>
		<pubDate>Tue, 12 Dec 2006 12:20:59 -0800</pubDate>
		<dc:creator>pmbuko</dc:creator>
	</item><item>
		<title>By: grouse</title>
		<link>http://ask.metafilter.com/52998/Scripting-the-parallel-execution-of-a-tedious-task#799008</link>	
		<description>pmbuko: What error?&lt;br&gt;
&lt;br&gt;
Also, did you try using bg instead as Good Brain suggested?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.52998-799008</guid>
		<pubDate>Tue, 12 Dec 2006 12:28:30 -0800</pubDate>
		<dc:creator>grouse</dc:creator>
	</item><item>
		<title>By: pmbuko</title>
		<link>http://ask.metafilter.com/52998/Scripting-the-parallel-execution-of-a-tedious-task#799013</link>	
		<description>on the mac, bg can be used on a job that has just been stopped, not while invoking a command.&lt;br&gt;
&lt;br&gt;
The error I get by having the ampersand in the script is:&lt;br&gt;
&lt;code&gt;&lt;br&gt;
-bash: syntax error near unexpected token `;&apos;&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
The ampersand immediately precedes the ;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.52998-799013</guid>
		<pubDate>Tue, 12 Dec 2006 12:31:19 -0800</pubDate>
		<dc:creator>pmbuko</dc:creator>
	</item><item>
		<title>By: pmbuko</title>
		<link>http://ask.metafilter.com/52998/Scripting-the-parallel-execution-of-a-tedious-task#799017</link>	
		<description>ooops! My bad. The &amp;amp; works like a charm.  It&apos;s the extraneous ; I added that was the problem.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.52998-799017</guid>
		<pubDate>Tue, 12 Dec 2006 12:33:36 -0800</pubDate>
		<dc:creator>pmbuko</dc:creator>
	</item><item>
		<title>By: Rhomboid</title>
		<link>http://ask.metafilter.com/52998/Scripting-the-parallel-execution-of-a-tedious-task#799024</link>	
		<description>You can skip the whole while/read thing also.&lt;br&gt;
&lt;br&gt;
&lt;tt&gt;for D in $(diskutil list | grep /disk | grep -v disk0 | sed &apos;s|/dev/||g&apos;); do diskutil zeroDisk $D &amp;amp; done&lt;/tt&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.52998-799024</guid>
		<pubDate>Tue, 12 Dec 2006 12:39:36 -0800</pubDate>
		<dc:creator>Rhomboid</dc:creator>
	</item><item>
		<title>By: pmbuko</title>
		<link>http://ask.metafilter.com/52998/Scripting-the-parallel-execution-of-a-tedious-task#799504</link>	
		<description>gotta love unix.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.52998-799504</guid>
		<pubDate>Tue, 12 Dec 2006 18:29:08 -0800</pubDate>
		<dc:creator>pmbuko</dc:creator>
	</item>
	</channel>
</rss>
