<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>KodeGeek &#187; bash</title>
	<atom:link href="http://kodegeek.com/blog/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://kodegeek.com/blog</link>
	<description>Programación, fitness, interés geek</description>
	<lastBuildDate>Sun, 29 Apr 2012 17:29:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Cuando Shell no es suficiente: Subshell</title>
		<link>http://kodegeek.com/blog/2008/04/10/cuando-shell-no-es-suficiente-subshell/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=cuando-shell-no-es-suficiente-subshell</link>
		<comments>http://kodegeek.com/blog/2008/04/10/cuando-shell-no-es-suficiente-subshell/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 10:54:00 +0000</pubDate>
		<dc:creator>josevnz</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[job control]]></category>
		<category><![CDATA[subshell]]></category>

		<guid isPermaLink="false">http://kodegeek.com/blog/?p=1240</guid>
		<description><![CDATA[OK, un pequeño ejercicio para el lector: Suponga que tenemos 5 tareas que toman bastante tiempo en completar: slowRubyScriptA slowRubyScriptB slowRubyScriptC slowRubyScriptD slowRubyScriptE slowRubyScriptF Y deben correr en el siguiente orden: B,C dependende de A D depende de C,B E,F tardan mucho más que los demás y no dependen de nadie Una forma de hacerlo [...]]]></description>
			<content:encoded><![CDATA[<p>OK, un pequeño ejercicio para el lector: Suponga que tenemos 5 tareas que toman bastante tiempo en completar:</p>
<ol>
<li>slowRubyScriptA</li>
<li>slowRubyScriptB</li>
<li>slowRubyScriptC</li>
<li>slowRubyScriptD</li>
<li>slowRubyScriptE</li>
<li>slowRubyScriptF</li>
</ol>
<p>Y deben correr en el siguiente orden:
<ul>
<li>B,C dependende de A</li>
<li>D depende de C,B</li>
<li>E,F tardan mucho más que los demás y no dependen de nadie</li>
</ul>
<p>Una forma de hacerlo es:
<pre><a name="line1"> </a>
<blockquote><a name="line1">1</a> #!/bin/bash<a name="line2"> 2</a> (<a name="line3"> 3</a> (<a name="line4"> 4</a> slowRubyScriptA<a name="line5"> 5</a> slowRubyScriptB &amp;<a name="line6"> 6</a> slowRubyScriptC &amp;<a name="line7"> 7</a> ) &amp;<a name="line8"> 8</a> wait<a name="line9"> 9</a> slowRubyScriptD<a name="line10">10</a> ) &amp;<a name="line11">11</a><a name="line12">12</a> slowRubyScriptE &amp;<a name="line13">13</a> slowRubyScriptF &amp;<a name="line14">14</a> wait<a name="line15">15</a> echo "All done"</blockquote>

</pre>
<p>Si, el ejemplo no es muy útil pero muestra una caracteristica muy útil de Bash y otros Shell: El uso de <span style="font-style: italic;">Subshells</span>. Fijese como no hubo necesidad de escribir otro script adicional para arrancar nuestros comandos.</p>
<p>Buscar en otros sitios:<br />Blogalaxia:<a href="http://www.blogalaxia.com/tags/bash" rel="tag">bash</a>, <a href="http://www.blogalaxia.com/tags/subshell" rel="tag">subshell</a>, <a href="http://www.blogalaxia.com/tags/job+control" rel="tag">job control</a><br />Technorati:<a href="http://technorati.com/tag/bash" rel="tag">bash</a>, <a href="http://technorati.com/tag/subshell" rel="tag">subshell</a>, <a href="http://technorati.com/tag/job+control" rel="tag">job control</a><br />To2blogs:<a href="http://www.to2blogs.com/tag/bash" rel="tag">bash</a>, <a href="http://www.to2blogs.com/tag/subshell" rel="tag">subshell</a>, <a href="http://www.to2blogs.com/tag/job+control" rel="tag">job control</a><br />Del.icio.us:<a href="http://del.icio.us/tag/bash" rel="tag">bash</a>, <a href="http://del.icio.us/tag/subshell" rel="tag">subshell</a>, <a href="http://del.icio.us/tag/job+control" rel="tag">job control</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kodegeek.com/blog/2008/04/10/cuando-shell-no-es-suficiente-subshell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trucos UNIX: ¿Como matar todos los procesos de un usuario?</title>
		<link>http://kodegeek.com/blog/2008/03/15/trucos-unix-%c2%bfcomo-matar-todos-los-procesos-de-un-usuario/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=trucos-unix-%25c2%25bfcomo-matar-todos-los-procesos-de-un-usuario</link>
		<comments>http://kodegeek.com/blog/2008/03/15/trucos-unix-%c2%bfcomo-matar-todos-los-procesos-de-un-usuario/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 14:19:00 +0000</pubDate>
		<dc:creator>josevnz</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[kill -9]]></category>
		<category><![CDATA[pkill]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://kodegeek.com/blog/?p=1237</guid>
		<description><![CDATA[Bueno, si usted tiene un montón de servidores a los cuales se puede conectar con SSH y lo quiere es matar todos los procesos de un usuario en particular, entonces puede usar algo como esto: 1 #!/bin/bash2 for machine in `cat myhostfile`; do3 ssh -x -q -f $machine "/usr/bin/pkill -9 -U myuser"4 done Funciona bajo [...]]]></description>
			<content:encoded><![CDATA[<p>Bueno, si usted tiene un montón de servidores a los cuales se puede conectar con SSH y lo quiere es matar todos los procesos de un usuario en particular, entonces puede usar algo como esto:</p>
<pre><a name="line1">1</a> <span style="color: rgb(0, 0, 255);"><strong>#!/bin/bash</strong></span><a name="line2">2</a> for machine in `cat myhostfile`; do<a name="line3">3</a>     ssh -x -q -f <span style="color: rgb(32, 64, 160);">$machine</span> <span style="color: rgb(0, 128, 0);">"/usr/bin/pkill -9 -U myuser"</span><a name="line4">4</a> done</pre>
<p>Funciona bajo Solaris 7 o superior y Linux. OS X por supuesto no lo tiene <img src='http://kodegeek.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Buscar en otros sitios:</p>
<p>Blogalaxia:<a href="http://www.blogalaxia.com/tags/pkill" rel="tag">pkill</a>, <a href="http://www.blogalaxia.com/tags/bash" rel="tag">bash</a>, <a href="http://www.blogalaxia.com/tags/ssh" rel="tag">ssh</a>, <a href="http://www.blogalaxia.com/tags/kill+-9" rel="tag">kill -9</a><br />Technorati:<a href="http://technorati.com/tag/pkill" rel="tag">pkill</a>, <a href="http://technorati.com/tag/bash" rel="tag">bash</a>, <a href="http://technorati.com/tag/ssh" rel="tag">ssh</a>, <a href="http://technorati.com/tag/kill+-9" rel="tag">kill -9</a><br />To2blogs:<a href="http://www.to2blogs.com/tag/pkill" rel="tag">pkill</a>, <a href="http://www.to2blogs.com/tag/bash" rel="tag">bash</a>, <a href="http://www.to2blogs.com/tag/ssh" rel="tag">ssh</a>, <a href="http://www.to2blogs.com/tag/kill+-9" rel="tag">kill -9</a><br />Del.icio.us:<a href="http://del.icio.us/tag/pkill" rel="tag">pkill</a>, <a href="http://del.icio.us/tag/bash" rel="tag">bash</a>, <a href="http://del.icio.us/tag/ssh" rel="tag">ssh</a>, <a href="http://del.icio.us/tag/kill+-9" rel="tag">kill -9</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kodegeek.com/blog/2008/03/15/trucos-unix-%c2%bfcomo-matar-todos-los-procesos-de-un-usuario/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Trucos UNIX: Cuando un alias no es suficiente</title>
		<link>http://kodegeek.com/blog/2007/06/18/trucos-unix-cuando-un-alias-no-es-suficiente/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=trucos-unix-cuando-un-alias-no-es-suficiente</link>
		<comments>http://kodegeek.com/blog/2007/06/18/trucos-unix-cuando-un-alias-no-es-suficiente/#comments</comments>
		<pubDate>Mon, 18 Jun 2007 10:00:00 +0000</pubDate>
		<dc:creator>josevnz</dc:creator>
				<category><![CDATA[alias]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://kodegeek.com/blog/?p=1147</guid>
		<description><![CDATA[A mi me encanta UNIX por su linea de comandos. Sin embargo también me da una pereza increible escribir algo tan largo como esto cada vez que quiero notificar a los directorios de blogs que mi página está actualizada: /Users/josevnz/bin/ping_controller.sh veneblogs,weblogs,technorati,bitacoras.com,pingomatic kodegeek http://kodegeek.com Asi que un alias cae como anillo al dedo: alias pingall=&#8217;/Users/josevnz/bin/ping_controller.sh veneblogs,weblogs,technorati,bitacoras.com,pingomatic [...]]]></description>
			<content:encoded><![CDATA[<p>A mi me encanta UNIX por su linea de comandos. Sin embargo también me da una pereza increible escribir algo tan largo como esto cada vez que quiero notificar a los directorios de blogs que mi página está actualizada:</p>
<p><span style="font-family:courier new;">/Users/josevnz/bin/ping_controller.sh veneblogs,weblogs,technorati,bitacoras.com,pingomatic kodegeek http://kodegeek.com</span></p>
<p>Asi que un alias cae como anillo al dedo:</p>
<p><span style="font-family:courier new;"><span style="color: rgb(255, 0, 0);">alias pingall</span>=&#8217;/Users/josevnz/bin/ping_controller.sh veneblogs,weblogs,technorati,bitacoras.com,pingomatic kodegeek http://kodegeek.com&#8217;</span></p>
<p>Para después escribir solamante &#8220;<span style="font-style: italic;">pingall</span>&#8220;.</p>
<p>Sin embargo, que ocurre si por ejemplo quisiera pasarle el titulo del blog a ciertos directorios como todosblogs.com cada vez que hago el ping:</p>
<p>pingall &#8220;Este es otro post del fabuloso Kodegeek&#8221;</p>
<p>Nada, no se puede. Con un alias estoy jodido porque no soportan argumentos.</p>
<p>Pero no todo está perdido. Para eso simplemente ponemos una pequeña función (les muestro la sintaxis en Bash) que nos haga el favor (primero haga <span style="font-style: italic;">unlias ping</span> para eliminar el viejo alias):</p>
<p><span style="font-family:courier new;">function pingall {</span> <span style="font-family:courier new;">/Users/josevnz/bin/ping_controller.sh veneblogs,weblogs,technorati,bitacoras.com,pingomatic kodegeek http://kodegeek.com $1</span> <span style="font-family:courier new;">}</span></p>
<p>Y si quiere guardar sus cambios entonces pongalos en su ~/.profile, ~/.bashrc o equivalente.</p>
<p>Blogalaxia.com:<a href="http://www.blogalaxia.com/tags/alias">alias</a>, <a href="http://www.blogalaxia.com/tags/bash">bash</a>, <a href="http://www.blogalaxia.com/tags/function">function</a>, <a href="http://www.blogalaxia.com/tags/unix">unix</a><br />Technorati.com:<a href="http://technorati.com/tag/alias">alias</a>, <a href="http://technorati.com/tag/bash">bash</a>, <a href="http://technorati.com/tag/function">function</a>, <a href="http://technorati.com/tag/unix">unix</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kodegeek.com/blog/2007/06/18/trucos-unix-cuando-un-alias-no-es-suficiente/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

