<?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>Dammit Jim! &#187; unix</title>
	<atom:link href="http://scott.sherrillmix.com/blog/tag/unix/feed/" rel="self" type="application/rss+xml" />
	<link>http://scott.sherrillmix.com/blog</link>
	<description>I'm a biologist not a...</description>
	<lastBuildDate>Mon, 06 Feb 2012 05:19:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Tab Indented Standard Input Redirect in Bash</title>
		<link>http://scott.sherrillmix.com/blog/programmer/tab-indented-standard-input-redirect-in-bash/</link>
		<comments>http://scott.sherrillmix.com/blog/programmer/tab-indented-standard-input-redirect-in-bash/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 02:52:43 +0000</pubDate>
		<dc:creator>ScottS-M</dc:creator>
				<category><![CDATA[Bash/UNIX]]></category>
		<category><![CDATA[Programmer]]></category>
		<category><![CDATA[EOF]]></category>
		<category><![CDATA[indent]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[standard input]]></category>
		<category><![CDATA[tab]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://scott.sherrillmix.com/blog/?p=502</guid>
		<description><![CDATA[I managed to forget how to redirect standard input (when you want to feed a bunch of lines to a program) in a bash script while still indenting and had to go digging around for it. So I figured I'd make a note here so I don't forget again and for anyone else in the [...]]]></description>
			<content:encoded><![CDATA[<p>I managed to forget how to redirect standard input (when you want to feed a bunch of lines to a program) in a bash script while still indenting and had to go digging around for it. So I figured I'd make a note here so I don't forget again and for anyone else in the same boat. It's just <code>&lt;&lt;-</code> instead of <code>&lt;&lt;</code>. For example if you want to keep indentation within a loop:</p>
<div class="syntax_hilite"><span class="langName">BASH:</span><br /><div id="bash-2">
<div class="bash"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">for</span> i <span style="color: #b1b100;">in</span> <span style="color: #cc66cc;color:#800000;">1</span> <span style="color: #cc66cc;color:#800000;">2</span> <span style="color: #cc66cc;color:#800000;">3</span> <span style="color: #cc66cc;color:#800000;">4</span>;do</div></li>
<li style="font-weight: bold;color:#26536A;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; cat&lt;&lt;-EOF</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; This is loop <span style="color: #0000ff;">$i</span></div></li>
<li style="font-weight: bold;color:#26536A;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; More advanced stuff could go here</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; EOF</div></li>
<li style="font-weight: bold;color:#26536A;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">done</span> </div></li></ol></div>
</div></div><br />
<p>You can use whatever you want to indicate the end of the input instead of EOF if it floats your boat (as long as you use the same thing both times) but unfortunately <code>&lt;&lt;-</code> doesn't work with spaces for indentation (although I'm a tab man myself).</p>
]]></content:encoded>
			<wfw:commentRss>http://scott.sherrillmix.com/blog/programmer/tab-indented-standard-input-redirect-in-bash/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using quotation marks effectively in Unix</title>
		<link>http://scott.sherrillmix.com/blog/programmer/using-quotation-marks-effectively-in-unix/</link>
		<comments>http://scott.sherrillmix.com/blog/programmer/using-quotation-marks-effectively-in-unix/#comments</comments>
		<pubDate>Sun, 26 Nov 2006 19:00:39 +0000</pubDate>
		<dc:creator>ScottS-M</dc:creator>
				<category><![CDATA[Bash/UNIX]]></category>
		<category><![CDATA[Programmer]]></category>
		<category><![CDATA[back]]></category>
		<category><![CDATA[backtick]]></category>
		<category><![CDATA[double]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pipe]]></category>
		<category><![CDATA[quotation marks]]></category>
		<category><![CDATA[quote]]></category>
		<category><![CDATA[single]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://scott.sherrillmix.com/blog/programmer/using-quotation-marks-effectively-in-unix/</guid>
		<description><![CDATA[This is pretty basic knowledge but I've helped a few people out recently that had been using Unix/Linux for a while and didn't know and it sure helped me out when I figured it out. If you had asked me how many quotation marks were on a keyboard before I started doing Bash stuff I [...]]]></description>
			<content:encoded><![CDATA[<p>This is pretty basic knowledge but I've helped a few people out recently that had been using Unix/Linux for a while and didn't know and it sure helped me out when I figured it out. If you had asked me how many quotation marks were on a keyboard before I started doing Bash stuff I would have said two. But I, and it seems most non-programmers, often forget the little <code>`</code> on the same key as the tilde ~ (to the left of the numbers on standard keyboards). So there are actually three types of quotation marks and each one means something different to Unix:</p>

<dl>
<dt>Single quote/forward quote <code style="font-size:150%;font-weight: bold;">'</code></dt><dd>Just for clarity this is the key next to the Enter key on most keyboards. A pair of single quotes tells Unix that the contents are a string and that it should not mess around inside. For example: <code>x=17;echo 'This is $x';</code> will return <code>This is $x</code>. Unix did not replace the variable <code>$x</code> with 17.
</dd>
<dt>Double quote <code style="font-size:150%;font-weight: bold;">"</code></dt><dd>Double quotes again tell Unix that the contents are a string. Double quotes and the above single quotes useful for keeping Unix from messing up spaces. For example: <code>grep "To be or not to be" hamlet.txt</code> will search hamlet.txt for the famous line. In contrast, <code>grep To be or not to be hamlet.txt</code> searches for <code>To</code> in the files <code>be, or, not, to, be, hamlet.txt</code> (not what was intended). Double quotes are different from single quotes in that they allow Unix to replace variables inside them. For example: <code>x=17;echo "This is $x";</code> will return <code>This is 17</code>.</dd>
<dt>Backtick/back quote <code style="font-size:150%;font-weight: bold;">`</code></dt><dd>Just for clarity this is the key shared with ~ on most keyboards. These are really different than the other two. They tell Unix to run whatever command is inside and paste in the output. These are equivalent to using <code>$()</code>. For example: <code>echo "You are in `pwd`"</code> will return <code>You are in /usr/bin/</code> or whatever directory you are in. These can come in really handy. One common use is looping through files. Here's a slightly more complex example that uses both double and back quotes to add the filename to every row in all text files in a directory: <code>for i in `ls *.txt`;do sed "s/^/$i /" $i >$i.new;done</code></dd>
</dl> 
<p>Knowing how these are used can really help with using Unix. The difference between <code>'commands'</code> and <code>"commands"</code> is pretty subtle but can make a big difference in the results. I learned this the hard way but hopefully now you won't have to.</p>.]]></content:encoded>
			<wfw:commentRss>http://scott.sherrillmix.com/blog/programmer/using-quotation-marks-effectively-in-unix/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Reading Standard Input in a Bash Shell Script</title>
		<link>http://scott.sherrillmix.com/blog/programmer/reading-standard-input-in-a-bash-shell-script/</link>
		<comments>http://scott.sherrillmix.com/blog/programmer/reading-standard-input-in-a-bash-shell-script/#comments</comments>
		<pubDate>Sat, 08 Jul 2006 12:34:01 +0000</pubDate>
		<dc:creator>ScottS-M</dc:creator>
				<category><![CDATA[Bash/UNIX]]></category>
		<category><![CDATA[Programmer]]></category>
		<category><![CDATA[ENTER]]></category>
		<category><![CDATA[get]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[read]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[standard input]]></category>
		<category><![CDATA[stdin]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://scott.sherrillmix.com/blog/uncategorized/reading-standard-input-in-a-bash-shell-script/</guid>
		<description><![CDATA[I guess this is obvious to most people but it took me quite a while to dig it out on the internet. I wanted my bash script to be able to read from standard input like cat sourcefile.txt&#124;bash myscript.bash. It turns out the standard input can be read from /dev/stdin. So if I wanted to [...]]]></description>
			<content:encoded><![CDATA[<p>I guess this is obvious to most people but it took me quite a while to dig it out on the internet. I wanted  my bash script to be able to read from standard input like <code>cat sourcefile.txt|bash myscript.bash</code>.  It turns out the standard input can be read from <code>/dev/stdin</code>. So if I wanted to <code>sort</code> the standard input, myscript.bash would look like: <code>sort /dev/stdin</code></p>

<p>I think this is probably basic UNIX knowledge but I'm not a programmer.</p>]]></content:encoded>
			<wfw:commentRss>http://scott.sherrillmix.com/blog/programmer/reading-standard-input-in-a-bash-shell-script/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

