<?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>Delivering Quality &#187; Bash</title>
	<atom:link href="http://www.markdeepwell.com/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markdeepwell.com</link>
	<description>A Software Developers View of the World</description>
	<lastBuildDate>Sat, 31 Dec 2011 22:41:24 +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>Bash Basics</title>
		<link>http://www.markdeepwell.com/2010/03/bash-basics/</link>
		<comments>http://www.markdeepwell.com/2010/03/bash-basics/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 20:47:33 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Basics]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Shell Scripting]]></category>

		<guid isPermaLink="false">http://www.markdeepwell.com/?p=490</guid>
		<description><![CDATA[Bash is a shell scripting language included on most Linux and Mac computers. It&#8217;s useful for writing small scripts that don&#8217;t require another software language to be installed and are immediately portable. Good places to use bash scripts are when you want to write a cronjob, backup some files, or run an update task. Here [...]]]></description>
			<content:encoded><![CDATA[<p>Bash is a shell scripting language included on most Linux and Mac computers. It&#8217;s useful for writing small scripts that don&#8217;t require another software language to be installed and are immediately portable. Good places to use bash scripts are when you want to write a cronjob, backup some files, or run an update task. Here are the basics to get you started.</p>
<p>Start your script with She-Bang header:<br />
<code>#!/bin/bash</code></p>
<p>Variables are assigned by a key-value pairing:<br />
<code>FILENAME="~/docs/input"</code></p>
<p>You can print to the console by using echo:<br />
<code>echo $FILENAME</code></p>
<p>An IF statement:<br />
<code>if [ ! -s $FILENAME ] ; then<br />
&nbsp;&nbsp;touch $FILENAME<br />
fi</code><br />
The bang ! negates the result, and the -s parameter checks if a file exists.</p>
<p>Example of a function:<br />
<code>function getFile<br />
{<br />
&nbsp;&nbsp;# function contents here<br />
&nbsp;&nbsp;# the hash symbol makes the rest of this line a comment<br />
}</code></p>
<p>Call this function by using its name:<br />
<code>getFile</code></p>
<p>You can pass a variable to a function:<br />
<code>getFile "/home/user/docs/file.txt"</code></p>
<p>And use it within the function by reference to $1<br />
<code>function getFile<br />
{<br />
&nbsp;&nbsp;echo $1<br />
}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.markdeepwell.com/2010/03/bash-basics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

