<?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>betweenGo &#187; Bash</title>
	<atom:link href="http://betweengo.com/category/os/unix/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://betweengo.com</link>
	<description>We make Ruby on Rails easy.  We make ATG easy.</description>
	<lastBuildDate>Tue, 06 Dec 2011 14:03:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Cygwin Bash Scripts and Java</title>
		<link>http://betweengo.com/2008/08/08/cygwin-bash-scripts-and-java/</link>
		<comments>http://betweengo.com/2008/08/08/cygwin-bash-scripts-and-java/#comments</comments>
		<pubDate>Sat, 09 Aug 2008 00:47:36 +0000</pubDate>
		<dc:creator>Frank Kim</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://betweengo.com/?p=268</guid>
		<description><![CDATA[Running Java scripts in Cygwin bash scripts becomes a little tricky because you want to treat most paths in Cygwin as normal UNIX paths but Java expects DOS paths.  Therefore to get around this you can use the mixed option for cygpath. For example: if [ -e /usr/bin/cygpath ] &#124;&#124; [ -e /bin/cygpath ] then [...]
Related posts:<ol>
<li><a href='http://betweengo.com/2007/03/07/cygwin-bash-cannot-execute-dos-formatted-scripts/' rel='bookmark' title='Cygwin Bash cannot execute DOS formatted scripts'>Cygwin Bash cannot execute DOS formatted scripts</a></li>
<li><a href='http://betweengo.com/2008/05/09/maven-assembly-shell-scripts-unix-lf/' rel='bookmark' title='Maven Assembly Convert Shell Scripts to use UNIX LF&#8217;s'>Maven Assembly Convert Shell Scripts to use UNIX LF&#8217;s</a></li>
<li><a href='http://betweengo.com/2008/05/05/scripts-with-win-lfs-fail-cygwin/' rel='bookmark' title='Shell Scripts with Windows LF&#8217;s Fail in Latest Cygwin'>Shell Scripts with Windows LF&#8217;s Fail in Latest Cygwin</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Running Java scripts in Cygwin bash scripts becomes a little tricky because you want to treat most paths in Cygwin as normal UNIX paths but Java expects DOS paths.  Therefore to get around this you can use the mixed option for cygpath.</p>
<p>For example:</p>
<pre>if [ -e /usr/bin/cygpath ] || [ -e /bin/cygpath ]
then
  export FOO=`cygpath --mixed "e:\work\betweengo/target/foo"`
else
  export FOO="e:\work\betweengo/target/foo"
fi</pre>
<p>The result on Cygwin is that FOO will be set to &#8220;e:/work/betweengo/target/foo&#8221; which will work both in DOS and UNIX.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbetweengo.com%2F2008%2F08%2F08%2Fcygwin-bash-scripts-and-java%2F&amp;title=Cygwin%20Bash%20Scripts%20and%20Java" id="wpa2a_2"><img src="http://betweengo.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>Related posts:<ol>
<li><a href='http://betweengo.com/2007/03/07/cygwin-bash-cannot-execute-dos-formatted-scripts/' rel='bookmark' title='Cygwin Bash cannot execute DOS formatted scripts'>Cygwin Bash cannot execute DOS formatted scripts</a></li>
<li><a href='http://betweengo.com/2008/05/09/maven-assembly-shell-scripts-unix-lf/' rel='bookmark' title='Maven Assembly Convert Shell Scripts to use UNIX LF&#8217;s'>Maven Assembly Convert Shell Scripts to use UNIX LF&#8217;s</a></li>
<li><a href='http://betweengo.com/2008/05/05/scripts-with-win-lfs-fail-cygwin/' rel='bookmark' title='Shell Scripts with Windows LF&#8217;s Fail in Latest Cygwin'>Shell Scripts with Windows LF&#8217;s Fail in Latest Cygwin</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://betweengo.com/2008/08/08/cygwin-bash-scripts-and-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Save the Output in a Shell Script Array</title>
		<link>http://betweengo.com/2007/12/14/save-the-output-in-a-shell-script-array/</link>
		<comments>http://betweengo.com/2007/12/14/save-the-output-in-a-shell-script-array/#comments</comments>
		<pubDate>Fri, 14 Dec 2007 17:46:17 +0000</pubDate>
		<dc:creator>Frank Kim</dc:creator>
				<category><![CDATA[Bash]]></category>

		<guid isPermaLink="false">http://betweengo.com/uncategorized/2007/12/14/save-the-output-in-a-shell-script-array/</guid>
		<description><![CDATA[I wanted to do some shell processing on the contents of a directory. To do this I needed to put the contents of the directory in an array. Fortunately this is not difficult with bash. First capture the output. ls_output=$(ls /images) Next declare an array and reference the output with this array. declare -a img_files [...]
Related posts:<ol>
<li><a href='http://betweengo.com/2007/12/14/save-the-output-in-a-variable/' rel='bookmark' title='Save the Output in a Shell Script Variable'>Save the Output in a Shell Script Variable</a></li>
<li><a href='http://betweengo.com/2007/03/28/printing-out-an-array/' rel='bookmark' title='Printing out an array'>Printing out an array</a></li>
<li><a href='http://betweengo.com/2007/03/07/unable-to-start-sh-from-windows-command-prompt/' rel='bookmark' title='Unable to start Cygwin shell from Windows command prompt'>Unable to start Cygwin shell from Windows command prompt</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I wanted to do some shell processing on the contents of a directory.  To do this I needed to put the contents of the directory in an array.  Fortunately this is not difficult with bash.</p>
<ol>
<li>First capture the output.
<p><code>ls_output=$(ls /images)</code></li>
<li>Next declare an array and reference the output with this array.
<p><code>declare -a img_files</code><br />
<code>img_files=($ls_output)</code></li>
<li>Now you can access the array directly or loop through it.
<p><code>echo ${img_files[0]}</code><br />
<code>for img_file in ${img_files[@]}</code><br />
<code>do</code><br />
<code>&nbsp;&nbsp;...</code><br />
<code>done</code></li>
</ol>
<p>Thanks <a href="http://safari.oreilly.com/0596526784/parsing_output_into_an_array">O&#8217;Reilly&#8217;s Bash Cookbook</a>.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbetweengo.com%2F2007%2F12%2F14%2Fsave-the-output-in-a-shell-script-array%2F&amp;title=Save%20the%20Output%20in%20a%20Shell%20Script%20Array" id="wpa2a_4"><img src="http://betweengo.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>Related posts:<ol>
<li><a href='http://betweengo.com/2007/12/14/save-the-output-in-a-variable/' rel='bookmark' title='Save the Output in a Shell Script Variable'>Save the Output in a Shell Script Variable</a></li>
<li><a href='http://betweengo.com/2007/03/28/printing-out-an-array/' rel='bookmark' title='Printing out an array'>Printing out an array</a></li>
<li><a href='http://betweengo.com/2007/03/07/unable-to-start-sh-from-windows-command-prompt/' rel='bookmark' title='Unable to start Cygwin shell from Windows command prompt'>Unable to start Cygwin shell from Windows command prompt</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://betweengo.com/2007/12/14/save-the-output-in-a-shell-script-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Save the Output in a Shell Script Variable</title>
		<link>http://betweengo.com/2007/12/14/save-the-output-in-a-variable/</link>
		<comments>http://betweengo.com/2007/12/14/save-the-output-in-a-variable/#comments</comments>
		<pubDate>Fri, 14 Dec 2007 17:40:45 +0000</pubDate>
		<dc:creator>Frank Kim</dc:creator>
				<category><![CDATA[Bash]]></category>

		<guid isPermaLink="false">http://betweengo.com/bash/2007/12/14/save-the-output-in-a-variable/</guid>
		<description><![CDATA[I was counting how many times a file was referenced by other files. I then wanted to do some processing based on this number. To do this I saved the output of this count in a variable which I was then able to reference later in the shell script. num_files=`find . -type f -name '*.html' [...]
Related posts:<ol>
<li><a href='http://betweengo.com/2007/12/14/save-the-output-in-a-shell-script-array/' rel='bookmark' title='Save the Output in a Shell Script Array'>Save the Output in a Shell Script Array</a></li>
<li><a href='http://betweengo.com/2008/05/09/maven-assembly-shell-scripts-unix-lf/' rel='bookmark' title='Maven Assembly Convert Shell Scripts to use UNIX LF&#8217;s'>Maven Assembly Convert Shell Scripts to use UNIX LF&#8217;s</a></li>
<li><a href='http://betweengo.com/2005/08/26/shell-tricks/' rel='bookmark' title='Shell Tricks'>Shell Tricks</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I was counting how many times a file was referenced by other files.  I then wanted to do some processing based on this number.</p>
<p>To do this I saved the output of this count in a variable which I was then able to reference later in the shell script.</p>
<p><code>num_files=`find . -type f -name '*.html' | xargs grep $img_file | wc -l`</code></p>
<p><code># delete this file if it is not referenced</code><br />
<code>if [ "0" = $num_files ]</code><br />
<code>then</code><br />
<code>&nbsp;&nbsp;rm $IMAGE_DIR/$img_file</code><br />
<code>fi</code></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbetweengo.com%2F2007%2F12%2F14%2Fsave-the-output-in-a-variable%2F&amp;title=Save%20the%20Output%20in%20a%20Shell%20Script%20Variable" id="wpa2a_6"><img src="http://betweengo.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>Related posts:<ol>
<li><a href='http://betweengo.com/2007/12/14/save-the-output-in-a-shell-script-array/' rel='bookmark' title='Save the Output in a Shell Script Array'>Save the Output in a Shell Script Array</a></li>
<li><a href='http://betweengo.com/2008/05/09/maven-assembly-shell-scripts-unix-lf/' rel='bookmark' title='Maven Assembly Convert Shell Scripts to use UNIX LF&#8217;s'>Maven Assembly Convert Shell Scripts to use UNIX LF&#8217;s</a></li>
<li><a href='http://betweengo.com/2005/08/26/shell-tricks/' rel='bookmark' title='Shell Tricks'>Shell Tricks</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://betweengo.com/2007/12/14/save-the-output-in-a-variable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
