<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>*nix Shell</title>
	<atom:link href="http://nixshell.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://nixshell.wordpress.com</link>
	<description>UNIX / Linux Shell Hints and Tips&#160;&#160;&#160;&#160;&#160;&#160;(a http://steve-parker.org/sh/sh.shtml subproject)</description>
	<lastBuildDate>Sat, 16 May 2009 00:39:13 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
		<url>http://www.gravatar.com/blavatar/9e458530f96756db742005af0b123d60?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>*nix Shell</title>
		<link>http://nixshell.wordpress.com</link>
	</image>
			<item>
		<title>Linux Command Directory</title>
		<link>http://nixshell.wordpress.com/2009/05/16/linux-command-directory/</link>
		<comments>http://nixshell.wordpress.com/2009/05/16/linux-command-directory/#comments</comments>
		<pubDate>Sat, 16 May 2009 00:39:13 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[MLP]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=107</guid>
		<description><![CDATA[I just found this page on the OReilly website &#8211; a Linux Command Directory
Click on any of the 687 commands below to get a description and list of available options. All links in the command summaries point to the online version of the book on Safari Bookshelf.
It doesn&#8217;t cover everything (what could?) but it could [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=107&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I just found this page on the OReilly website &#8211; a <a href="http://oreilly.com/linux/command-directory/">Linux Command Directory</a></p>
<blockquote><p>Click on any of the 687 commands below to get a description and list of available options. All links in the command summaries point to the online version of the book on Safari Bookshelf.</p></blockquote>
<p>It doesn&#8217;t cover everything (what could?) but it could be a useful page to bookmark.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/107/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=107&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2009/05/16/linux-command-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>awk one-liners</title>
		<link>http://nixshell.wordpress.com/2009/04/01/awk-one-liners/</link>
		<comments>http://nixshell.wordpress.com/2009/04/01/awk-one-liners/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 22:05:31 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[MLP]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[sed]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=98</guid>
		<description><![CDATA[I have previously plugged the great list of sed 1-liners at http://sed.sourceforge.net/sed1line.txt.
Here is a similar (if shorter) list of handy awk 1-liners:
http://www.sap-basis-abap.com/unix/awk-one-liner-tips.htm:
Print column1, column5 and column7 of a data file or output of any columns list
awk '{print $1, $5, $7}' data_file
cat file_name &#124;awk '{print $1 $5 $7}'
ls –al &#124;awk '{print $1, $5, $7}' -- Prints [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=98&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have previously plugged the great list of sed 1-liners at <a href="http://sed.sourceforge.net/sed1line.txt">http://sed.sourceforge.net/sed1line.txt</a>.</p>
<p>Here is a similar (if shorter) list of handy awk 1-liners:</p>
<p><a href="http://www.sap-basis-abap.com/unix/awk-one-liner-tips.htm">http://www.sap-basis-abap.com/unix/awk-one-liner-tips.htm</a>:</p>
<p><strong>Print column1, column5 and column7 of a data file or output of any columns list</strong></p>
<p><code>awk '{print $1, $5, $7}' data_file</p>
<p>cat file_name |awk '{print $1 $5 $7}'</p>
<p>ls –al |awk '{print $1, $5, $7}' -- Prints file_permissions,size and date<br />
</code><br />
<strong>List all files names whose file size greater than zero.</strong></p>
<p><code>ls –al |awk '$5 &gt; 0 {print $9}'<br />
</code><br />
<strong>List all files whose file size equal to 512bytes.<br />
</strong><br />
<code>ls –al |awk '$5 == 0 {print $9}'</code></p>
<p><strong>print all lines</strong></p>
<p><code>awk '{print }' file_name</p>
<p>awk '{print 0}' file_name</code><br />
<strong><br />
Number of lines in a file</strong><br />
<code><br />
awk ' END {print NR}' file_name<br />
</code><br />
<strong>Number of columns in each row of a file<br />
</strong><br />
<code>awk '{print NF}' file_name<br />
</code><br />
<strong>Sort the output of file and eliminate duplicate rows<br />
</strong><br />
<code>awk '{print $1, $5, $7}' |sort –u<br />
</code><br />
<strong>List all file names whose file size is greater than 512bytes and owner is &#8220;oracle&#8221;<br />
</strong><br />
<code>ls –al |awk '$3 == "oracle" &amp;&amp; $5 &gt; 512 {print $9}'<br />
</code><br />
<strong>List all file names whose owner could be either &#8220;oracle&#8221; or &#8220;root&#8221;<br />
</strong><br />
<code>ls –al |awk '$3 == "oracle" || $3 == "root" {print $9}'<br />
</code><br />
<strong>list all the files whose owner is not &#8220;oracle<br />
</strong><br />
<code>ls –al |awk '$3 != "oracle" {print $9}'<br />
</code><br />
<strong>List all lines which has at least one or more characters<br />
</strong><br />
<code>awk 'NF &gt; 0 {print }' file_name<br />
</code><br />
<strong>List all lines longer that 50 characters<br />
</strong><br />
<code>awk 'length($0) &gt; 50 {print }' file_name<br />
</code><br />
<strong>List first two columns<br />
</strong><br />
<code>awk '{print $1, $2}' file_name<br />
</code><br />
<strong>Swap first two columns of a file and print<br />
</strong><br />
<code>awk '{temp = $1; $1 = $2; $2 = temp; print }' file_name<br />
</code><br />
<strong>Replace first column as &#8220;ORACLE&#8221; in a data file<br />
</strong><br />
<code>awk '{$1 = "ORACLE"; print }' data_file<br />
</code><br />
<strong>Remove first column values in a data file<br />
</strong><br />
<code>awk '{$1 =""; print }' data_file<br />
</code><br />
<strong>Calculate total size of a directory in Mb<br />
</strong><code><br />
ls –al |awk '{total +=$5};END {print "Total size: " total/1024/1024 " Mb"}'<br />
</code><strong><br />
Calculate total size of a directory including sub directories in Mb<br />
</strong><code><br />
ls –lR |awk '{total +=$5};END {print "Total size: " total/1024/1024 " Mb"}'</code><br />
<strong><br />
Find largest file in a directory including sub directories<br />
</strong><br />
<code>ls –lR |awk '{print $5 "\t" $9}' |sort –n |tail -1 </code></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/98/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=98&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2009/04/01/awk-one-liners/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Saving, Escaping, and Restoring positional parameters in a POSIX shell</title>
		<link>http://nixshell.wordpress.com/2009/03/21/saving-escaping-and-restoring-positional-parameters-in-a-posix-shell/</link>
		<comments>http://nixshell.wordpress.com/2009/03/21/saving-escaping-and-restoring-positional-parameters-in-a-posix-shell/#comments</comments>
		<pubDate>Sat, 21 Mar 2009 23:44:35 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=94</guid>
		<description><![CDATA[http://www.seanius.net/blog/2009/03/saving-and-restoring-positional-params/ has a really good post about how &#8220;shift&#8221; loses the original command-line arguments, discusses various seemingly-obvious ways of restoring them, explores why they fail for certain types of input, and provides what seems to be a working solution:
one way you could try to store/save them would be to save the original copy of $@ [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=94&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://www.seanius.net/blog/2009/03/saving-and-restoring-positional-params/">http://www.seanius.net/blog/2009/03/saving-and-restoring-positional-params/</a> has a really good post about how &#8220;shift&#8221; loses the original command-line arguments, discusses various seemingly-obvious ways of restoring them, explores why they fail for certain types of input, and provides what seems to be a working solution:</p>
<blockquote><p>one way you could try to store/save them would be to save the original copy of $@ and use eval set &#8212; later on to change it back to the saved variable</p></blockquote>
<p>&#8230; but as it turns out, that doesn&#8217;t work with spaces, or quotes. Excellent, really concise description of the problem(s) and solution(s).</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/94/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=94&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2009/03/21/saving-escaping-and-restoring-positional-parameters-in-a-posix-shell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Using GNU Grep for Fun and Profit!</title>
		<link>http://nixshell.wordpress.com/2009/02/11/using-gnu-grep-for-fun-and-profit/</link>
		<comments>http://nixshell.wordpress.com/2009/02/11/using-gnu-grep-for-fun-and-profit/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 02:03:42 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=91</guid>
		<description><![CDATA[Shell Script: GetCluster &#8211; a shell script I happen to have written today; uses a few features of GNU Grep, whilst being tolerant of non-GNU greps (at the cost of some functionality).
This simple shell script is an example of the kind of thing that can easily be done with a few simple commands. As it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=91&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://steve-parker.org/urandom/comment.php?art=693">Shell Script: GetCluster</a> &#8211; a shell script I happen to have written today; uses a few features of GNU Grep, whilst being tolerant of non-GNU greps (at the cost of some functionality).</p>
<p>This simple shell script is an example of the kind of thing that can easily be done with a few simple commands. As it is intended for the Solaris platform, which does not necessarily include GNU&#8217;s grep, some additional complexity is required to see what the platform&#8217;s grep utility is capable of.</p>
<p>This is achieved by:<br />
1) Set the PATH to pick up the GNU tools first: <code>PATH=/usr/sfw/bin:$PATH</code><br />
2) Find grep (ggrep if possible; the existence of ggrep suggests that grep itself is not GNU&#8217;s grep):<br />
<code>type ggrep &gt;/dev/null 2&gt;&amp;1<br />
if [ "$?" -eq "0" ]; then<br />
  GREP=`which ggrep`<br />
else<br />
  GREP=`which grep`<br />
fi<br />
</code></p>
<p>It then finds a file, which could be in one of many places:<br />
<code>CLUSTERTOC=`ls clustertoc .clustertoc /cdrom/cdrom0/Solaris*/Product/.clustertoc /cdrom/Solaris*/Product/.clustertoc /mnt/Solaris*/Product/.clustertoc 2&gt;/dev/null|head -1`</code><br />
What this does, is identify the first succesful match (the rest go to /dev/null). If none is found, the CLUSTERTOC will not be a valid file (note: this gets us the added bonus that it will complain if clustertoc is a device driver, pipe, etc).</p>
<p>It then looks for &#8220;SUNW_CSRMEMBER&#8221; in the clustertoc, using &#8220;<code>grep -n</code>&#8221; to get the line number, then passing that linenumber on to <code>head</code> so as to limit the output to only contain those lines. Any lines below that point would refer to other clusters, and be irrelevant. We want to get the last of the relevant part of the file, so that the <code>tail</code> command below will give us what we need.</p>
<p>GNU Grep has a &#8220;-A n&#8221; and &#8220;-B n&#8221; facility to say &#8220;include n lines After the matching line&#8221; or &#8220;include n lines Before the matching line&#8221;. We use &#8220;-A&#8221; here to get the following lines which describe the pacakge in more detail:<br />
<code>   head -${linenum} $CLUSTERTOC |$GREP -A4 "^CLUSTER="|cut -d"=" -f2-|tail -4</code></p>
<p>See the <a href="http://steve-parker.org/code/sh/getcluster/readme.txt">readme</a> file for specific output &#8211; the Solaris (non-GNU) version has notably less detail than the GNU version. </p>
<p>Hopefully the script (<a href="http://steve-parker.org/code/sh/getcluster/getcluster.sh">http://steve-parker.org/code/sh/getcluster/getcluster.sh</a>) is in other ways sufficiently self-explanatory.</p>
<p>The input file (<a href="http://steve-parker.org/code/sh/getcluster/clustertoc">http://steve-parker.org/code/sh/getcluster/clustertoc</a> is relatively simple, and should explain any other queries.</p>
<p>Still &#8211; this simple script may provoke a few questions; please do play with it and ask away, if anything is unclear. </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/91/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=91&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2009/02/11/using-gnu-grep-for-fun-and-profit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Happy Second Birthday!</title>
		<link>http://nixshell.wordpress.com/2009/01/21/happy-second-birthday/</link>
		<comments>http://nixshell.wordpress.com/2009/01/21/happy-second-birthday/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 01:41:07 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=85</guid>
		<description><![CDATA[I have missed the second birthday of this blog; starting with Hello World on 17th January 2007, this blog has seen a small growth, but the comments posted show that people have found it to be useful, which is good.
I hope that you continue to find it useful; I really will try to post a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=85&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have missed the second birthday of this blog; starting with <a href="http://nixshell.wordpress.com/2007/01/17/hello-world/">Hello World</a> on 17th January 2007, this blog has seen a small growth, but the comments posted show that people have found it to be useful, which is good.</p>
<div id="attachment_87" class="wp-caption aligncenter" style="width: 310px"><img src="http://nixshell.files.wordpress.com/2009/01/traffic.gif?w=300&#038;h=150" alt="Traffic" title="traffic" width="300" height="150" class="size-medium wp-image-87" /><p class="wp-caption-text">Traffic</p></div>
<div id="attachment_86" class="wp-caption aligncenter" style="width: 310px"><img src="http://nixshell.files.wordpress.com/2009/01/stats.gif?w=300&#038;h=242" alt="Statistics" title="stats" width="300" height="242" class="size-medium wp-image-86" /><p class="wp-caption-text">Statistics</p></div>
<p>I hope that you continue to find it useful; I really will try to post a bit more often in 2009!</p>
<p>Steve</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/85/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=85&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2009/01/21/happy-second-birthday/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>

		<media:content url="http://nixshell.files.wordpress.com/2009/01/traffic.gif?w=300" medium="image">
			<media:title type="html">traffic</media:title>
		</media:content>

		<media:content url="http://nixshell.files.wordpress.com/2009/01/stats.gif?w=300" medium="image">
			<media:title type="html">stats</media:title>
		</media:content>
	</item>
		<item>
		<title>A very happy Christmas to all readers</title>
		<link>http://nixshell.wordpress.com/2008/12/24/a-very-happy-christmas-to-all-readers/</link>
		<comments>http://nixshell.wordpress.com/2008/12/24/a-very-happy-christmas-to-all-readers/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 22:14:38 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=82</guid>
		<description><![CDATA[echo unccl puevfgznf &#124; tr A-Za-z N-ZA-Mn-za-m
This is a very simplistic thing called &#8220;rot13&#8243;, whereby &#8220;a&#8221; becomes &#8220;n&#8221;, &#8220;b&#8221; becomes &#8220;o&#8221;, &#8220;c&#8221; becomes &#8220;p&#8221;, and so on. The tr utility is ideal for simple string manipulation like this.
Happy Christmas to all!
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=82&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><code>echo unccl puevfgznf | tr A-Za-z N-ZA-Mn-za-m</code></p>
<p>This is a very simplistic thing called &#8220;rot13&#8243;, whereby &#8220;a&#8221; becomes &#8220;n&#8221;, &#8220;b&#8221; becomes &#8220;o&#8221;, &#8220;c&#8221; becomes &#8220;p&#8221;, and so on. The <code>tr</code> utility is ideal for simple string manipulation like this.</p>
<p>Happy Christmas to all!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/82/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=82&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2008/12/24/a-very-happy-christmas-to-all-readers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>ssh port forwarding without starting a new session</title>
		<link>http://nixshell.wordpress.com/2008/12/10/ssh-port-forwarding-without-starting-a-new-session/</link>
		<comments>http://nixshell.wordpress.com/2008/12/10/ssh-port-forwarding-without-starting-a-new-session/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 16:53:56 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[MLP]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=79</guid>
		<description><![CDATA[You can forward ports with ssh like this:
$ ssh -L 8080:localhost:80 user@remotehost
This will log you in to remotehost as user, and port 8080 on your local machine will be tunnelled to port 80 on remotehost. If remotehost can see a machine that you can&#8217;t (for example, if it&#8217;s on an internal network), you can even [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=79&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>You can forward ports with ssh like this:</p>
<p><code>$ <strong>ssh -L 8080:localhost:80 user@remotehost</strong></code></p>
<p>This will log you in to <code>remotehost</code> as <code>user</code>, and port <code>8080</code> on your local machine will be tunnelled to port <code>80</code> on <code>remotehost</code>. If remotehost can see a machine that you can&#8217;t (for example, if it&#8217;s on an internal network), you can even do this:</p>
<p><code>$ <strong>ssh -L 8080:internalhost:80 user@borderhost</strong></code></p>
<p>This will log you in to <code>borderhost</code>, and <code>localhost:8080</code> will be directed to <code>internalhost:80</code>, even though you may not be able to see <code>internalhost</code> directly yourself.</p>
<p>What I didn&#8217;t know until I read <a href="http://nion.modprobe.de/blog/archives/656-ssh-on-the-fly-port-forwarding.html">Nico Golde&#8217;s blog today</a>, is that you can do this interactively, with an existing session. Tilde (~) is the default escape character, and ~C (note that&#8217;s an uppercase C) gets you a shell session within ssh itself:</p>
<p><code>$ <strong>ssh user@remotehost</strong><br />
user@remotehost$ <strong>~C</strong><br />
ssh&gt; <strong>-L 8080:localhost:80</strong><br />
Forwarding port.<br />
user@remotehost$ </code></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/79/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=79&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2008/12/10/ssh-port-forwarding-without-starting-a-new-session/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Emptying deleted files</title>
		<link>http://nixshell.wordpress.com/2008/11/08/emptying-deleted-files/</link>
		<comments>http://nixshell.wordpress.com/2008/11/08/emptying-deleted-files/#comments</comments>
		<pubDate>Sat, 08 Nov 2008 00:07:40 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[MLP]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=77</guid>
		<description><![CDATA[Mike Hommey has a nice article on clearing down deleted (but still-open) files:
http://glandium.org/blog/?p=211. He explains the problem clearly, and goes on to provide the solution, too. Well worth bookmarking, for that 2am emergency!
someone had to free some space on a 1GB filesystem, and thought a good idea would be to delete that 860MB log file [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=77&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Mike Hommey has a nice article on clearing down deleted (but still-open) files:<br />
<a href="http://glandium.org/blog/?p=211">http://glandium.org/blog/?p=211</a>. He explains the problem clearly, and goes on to provide the solution, too. Well worth bookmarking, for that 2am emergency!</p>
<blockquote><p>someone had to free some space on a 1GB filesystem, and thought a good idea would be to delete that 860MB log file that nobody cares about. Except that it didn’t really remove it, but he didn’t really check.</p>
<p>Later, the “filesystem full” problem came back at someone else, who came to ask me what files from a small list he could remove. But the files were pretty small, and that wouldn’t have freed enough space. That gave me the feeling that we probably were in this typical case I introduced this post with, which du -sk confirmed: 970MB used on the filesystem according to df, but only 110MB worth of data…</p></blockquote>
<p>Mike has solutions to this for Solaris and Linux; <code>lsof</code> is also useful for this kind of thing, on systems which have it.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/77/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=77&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2008/11/08/emptying-deleted-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>more (or less) vi</title>
		<link>http://nixshell.wordpress.com/2008/10/17/more-or-less-vi/</link>
		<comments>http://nixshell.wordpress.com/2008/10/17/more-or-less-vi/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 00:32:12 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=75</guid>
		<description><![CDATA[When using the more tool (this works with less, also, and less is generally more useful; you can scroll backwards and forwards with less), you can press &#8220;v&#8221; to start editing the file, in vi, at the line you are currently viewing.
This works on Linux and Solaris; please confirm on other OSes as appropriate, though [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=75&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>When using the <code>more</code> tool (this works with <code>less</code>, also, and <code>less</code> is generally more useful; you can scroll backwards and forwards with <code>less</code>), you can press &#8220;<code>v</code>&#8221; to start editing the file, in <code>vi</code>, at the line you are currently viewing.</p>
<p>This works on Linux and Solaris; please confirm on other OSes as appropriate, though I would assume that what works on <code>more</code> on Solaris, will work on <code>more</code> or <code>less</code> on just about any OS.</p>
<p>This makes using <code>more</code> or <code>less</code> far more powerful than before, and a new way into <code>vi</code>.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/75/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=75&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2008/10/17/more-or-less-vi/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>chmod syntax&#8230; be careful!</title>
		<link>http://nixshell.wordpress.com/2008/09/09/chmod-syntax-be-careful/</link>
		<comments>http://nixshell.wordpress.com/2008/09/09/chmod-syntax-be-careful/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 23:05:36 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=73</guid>
		<description><![CDATA[Ben Hutchings has noted a quirk in the chmod syntax: If you use the &#8220;chmod o-x&#8221; syntax, but omit the &#8220;o&#8221; (Others) (or the &#8220;u&#8221; (User) or &#8220;g&#8221; (Group)), it will default to &#8220;a&#8221; (All).
So &#8220;chmod -x foo&#8221; becomes &#8220;chmod a-x foo&#8220;; similarly, &#8220;chmod +x foo&#8221; becomes &#8220;chmod a+x foo&#8220;
      [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=73&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Ben Hutchings has noted a <a href="http://womble.decadent.org.uk/blog/chmod--x-considered-harmful">quirk in the chmod syntax</a>: If you use the &#8220;<code>chmod o-x</code>&#8221; syntax, but omit the &#8220;<code>o</code>&#8221; (Others) (or the &#8220;<code>u</code>&#8221; (User) or &#8220;<code>g</code>&#8221; (Group)), it will default to &#8220;<code>a</code>&#8221; (All).</p>
<p>So &#8220;<code>chmod -x foo</code>&#8221; becomes &#8220;<code>chmod a-x foo</code>&#8220;; similarly, &#8220;<code>chmod +x foo</code>&#8221; becomes &#8220;<code>chmod a+x foo</code>&#8220;</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nixshell.wordpress.com/73/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nixshell.wordpress.com/73/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/73/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=73&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2008/09/09/chmod-syntax-be-careful/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Bash History</title>
		<link>http://nixshell.wordpress.com/2008/09/01/bash-history/</link>
		<comments>http://nixshell.wordpress.com/2008/09/01/bash-history/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 23:32:03 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[history]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[MLP]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=71</guid>
		<description><![CDATA[Interesting list of 15 examples of bash history syntax.
Most people probably know #5:
# !ps
ps aux &#124; grep yp
I didn&#8217;t know #13, that looks really useful for arcane purposes:
# cp ~/longname.txt /really/a/very/long/path/long-filename.txt
# ls -l !cp:2
ls -l /really/a/very/long/path/long-filename.txt
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=71&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Interesting list of <a href="http://www.thegeekstuff.com/2008/08/15-examples-to-master-linux-command-line-history/">15 examples of bash history syntax</a>.</p>
<p>Most people probably know #5:<br />
<code># <b>!ps</b><br />
ps aux | grep yp</code></p>
<p>I didn&#8217;t know #13, that looks really useful for arcane purposes:<br />
<code># <b>cp ~/longname.txt /really/a/very/long/path/long-filename.txt</b><br />
# <b>ls -l !cp:2</b><br />
ls -l /really/a/very/long/path/long-filename.txt</code></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nixshell.wordpress.com/71/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nixshell.wordpress.com/71/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/71/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=71&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2008/09/01/bash-history/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Some useful Linux / *nix admin words of experience</title>
		<link>http://nixshell.wordpress.com/2008/08/21/some-useful-linux-nix-admin-words-of-experience/</link>
		<comments>http://nixshell.wordpress.com/2008/08/21/some-useful-linux-nix-admin-words-of-experience/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 00:54:18 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[MLP]]></category>
		<category><![CDATA[regexp]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=68</guid>
		<description><![CDATA[Entitled &#8220;Lazy Linux: 10 essential tricks for admins&#8220;, this is a pretty good set of essential commands for *nix administrators.
If I have to suggest anything for in-depth study, it&#8217;s &#8220;Trick 6&#8243;: &#8220;Remote VNC session through an SSH tunnel&#8221;, because you can actually do just about anything through an SSH tunnel. If you&#8217;re faced with you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=68&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Entitled &#8220;<a href="http://www.ibm.com/developerworks/linux/library/l-10sysadtips/index.html">Lazy Linux: 10 essential tricks for admins</a>&#8220;, this is a pretty good set of essential commands for *nix administrators.</p>
<p>If I have to suggest anything for in-depth study, it&#8217;s &#8220;Trick 6&#8243;: &#8220;Remote VNC session through an SSH tunnel&#8221;, because you can actually do just about anything through an SSH tunnel. If you&#8217;re faced with you -&gt; firewall -&gt; internet -&gt; remotemachine -&gt; internet -&gt; restoftheworld, you can do whatever you like with &#8220;restof theworld&#8221; if you can ssh to &#8220;remotemachine&#8221;, whatever the local firewall thinks. And you can probably ssh over port 443 through the firewall. Hmm; maybe I should write this up properly at some point. I&#8217;m sure it&#8217;s well documented on the web if you look for it&#8230;.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nixshell.wordpress.com/68/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nixshell.wordpress.com/68/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/68/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=68&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2008/08/21/some-useful-linux-nix-admin-words-of-experience/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Bash Quiz</title>
		<link>http://nixshell.wordpress.com/2008/06/09/bash-quiz/</link>
		<comments>http://nixshell.wordpress.com/2008/06/09/bash-quiz/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 22:26:24 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[quiz]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=67</guid>
		<description><![CDATA[Network Theory have a Bash Quiz!
Out of the ten questions, one I&#8217;m not immediately sure of without checking; another I only happened to come across earlier today, and one (echo "\'")I got wrong  
So, 7/10 really; 8/10 by good fortune of coming across the definition earlier today
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=67&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Network Theory have a <a href="http://www.network-theory.co.uk/articles/bash-quiz.html">Bash Quiz</a>!</p>
<p>Out of the ten questions, one I&#8217;m not immediately sure of without checking; another I only happened to come across earlier today, and one (<code>echo "\'"</code>)I got wrong <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p>So, 7/10 really; 8/10 by good fortune of coming across the definition earlier today</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nixshell.wordpress.com/67/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nixshell.wordpress.com/67/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/67/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=67&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2008/06/09/bash-quiz/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Book</title>
		<link>http://nixshell.wordpress.com/2008/04/23/book/</link>
		<comments>http://nixshell.wordpress.com/2008/04/23/book/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 00:35:25 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[Blogroll]]></category>
		<category><![CDATA[MLP]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[init]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pipes]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=66</guid>
		<description><![CDATA[A serious publisher has contacted me about writing a serious book about Linux shell programming.
It is all really very serious. I&#8217;m not used to being serious, as you can probably tell from the fact that I have now used the word &#8220;serious&#8221; four times in this three-sentence post.
I am rather keen to write a book [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=66&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A serious publisher has contacted me about writing a serious book about Linux shell programming.</p>
<p>It is all really very serious. I&#8217;m not used to being serious, as you can probably tell from the fact that I have now used the word &#8220;serious&#8221; four times in this three-sentence post.</p>
<p>I am rather keen to write a book on the subject, not because I&#8217;m vain, or desperate for money, but because the stuff I have seen out there in dead-tree format has been of rather low quality. Also because of all the emails I&#8217;ve received over the years, they have all been positive, and none has said anything along the lines of &#8220;I didn&#8217;t need any of that because I bought Book[X]&#8220;, or indeed any book.    People have emailed me, asking for advice as to what book to buy, and I have been unable to recommend any book that I have seen.</p>
<p>So:<br />
<strong><i><br />
What would you like to see in your ideal book about UNIX / Linux shell scripting, be it Bourne, Bash, ksh, tcsh, zsh, whatever?</i></strong></p>
<p>Please don&#8217;t be timid; if you want to know how to work out how many nose-flutes can be fitted into the area of a Boeing 757, you won&#8217;t be anything like as strange as some of the correspondants I&#8217;ve had over the years, so please, tell me what is bugging you, what has bugged you, or even what you think might be likely to bug you in days / months / years to come.</p>
<p>I&#8217;m likely to answer any specific questions here and now, whether or not they end up in the book, but anything you&#8217;d like to see in a book, too&#8230; post that here, and I&#8217;ll have a stab at it.</p>
<p>Also, I would of course be interested to know if you have found any useful books on or around the subject, and what they did particularly well.</p>
<p>Steve</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nixshell.wordpress.com/66/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nixshell.wordpress.com/66/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/66/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=66&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2008/04/23/book/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Happy First Birthday!</title>
		<link>http://nixshell.wordpress.com/2008/01/06/happy-first-birthday/</link>
		<comments>http://nixshell.wordpress.com/2008/01/06/happy-first-birthday/#comments</comments>
		<pubDate>Sun, 06 Jan 2008 02:28:24 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[MLP]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[init]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pipes]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/2008/01/06/happy-first-birthday/</guid>
		<description><![CDATA[This blog has now been running for a year; the first post was Hello World on 17th Jan 2007.
I hadn&#8217;t realised it had been going for so long; in that time, I&#8217;ve made 41 posts, so I haven&#8217;t quite managed to make one post per week     I have been a bit [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=65&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This blog has now been running for a year; the first post was <a href="http://nixshell.wordpress.com/2007/01/17/hello-world/">Hello World</a> on 17th Jan 2007.</p>
<p>I hadn&#8217;t realised it had been going for so long; in that time, I&#8217;ve made 41 posts, so I haven&#8217;t quite managed to make one post per week <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />    I have been a bit slack lately, for which I do apologise. New Years Resolution: I must make more posts here!</p>
<p>In the meantime, my main site, <a href="http://steve-parker.org/">steve-parker.org</a>, has celebrated its seventh birthday, having been born in June 2000 &#8211; looking forward to making the 8th birthday celebrations this June!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nixshell.wordpress.com/65/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nixshell.wordpress.com/65/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/65/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=65&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2008/01/06/happy-first-birthday/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Ordering items</title>
		<link>http://nixshell.wordpress.com/2007/11/07/ordering-items/</link>
		<comments>http://nixshell.wordpress.com/2007/11/07/ordering-items/#comments</comments>
		<pubDate>Wed, 07 Nov 2007 22:49:57 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/11/07/ordering-items/</guid>
		<description><![CDATA[There are lots of small little quirks to the *nix shells; this is just one of them.
If you want to list the files in a directory, then ls will list them all for you, in alphabetical order.
If you want to list them by size, you can use ls -S; by timestamp: ls -t, and so [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=64&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>There are lots of small little quirks to the *nix shells; this is just one of them.</p>
<p>If you want to list the files in a directory, then <code>ls</code> will list them all for you, in alphabetical order.</p>
<p>If you want to list them by size, you can use <code>ls -S</code>; by timestamp: <code>ls -t</code>, and so on.</p>
<p>But <code>ls</code> is a particular utility. What happens when we do this:</p>
<p><code><br />
for myfile in *<br />
do<br />
&nbsp;&nbsp;echo "My file is called $myfile"<br />
done</code></p>
<p>We get an alphabetically sorted list (see <code>man ascii</code> for the actual detail; they&#8217;re sorted by ASCII value, so numbers first, then uppercase letters, then lowercase letters).</p>
<p>This can be a pain, but it can also be quite useful. If you&#8217;ve got a bunch of files:</p>
<p><code>1.install.txt<br />
2.setup.txt<br />
3.use.txt<br />
4.uninstall.txt</code></p>
<p>Then you can play with them in order, just by using the asterisk:</p>
<p><code>for i in *<br />
do<br />
&nbsp;&nbsp;echo "File $i" &gt;&gt; all.txt<br />
&nbsp;&nbsp;cat $i &gt;&gt; all.txt<br />
done</code></p>
<p>And it will sort them into order for you (&#8221;1&#8243; comes before &#8220;2&#8243; in ASCII, and so on&#8230;)</p>
<p>Or you could just do this:</p>
<p><code>more * &gt; all.txt</code></p>
<p>Because <code>more</code> will prefix each file with its name in a header, if there is more than one file to process.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nixshell.wordpress.com/64/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nixshell.wordpress.com/64/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/64/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=64&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2007/11/07/ordering-items/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Maths in bash shell</title>
		<link>http://nixshell.wordpress.com/2007/09/28/maths-in-bash-shell/</link>
		<comments>http://nixshell.wordpress.com/2007/09/28/maths-in-bash-shell/#comments</comments>
		<pubDate>Fri, 28 Sep 2007 08:53:04 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/09/28/maths-in-bash-shell/</guid>
		<description><![CDATA[http://snap.nlc.dcccd.edu/reference/bash1/features_29.html has a bash-specific technique for processing calculations:

$[ expression ]
$(( expression ))

See the link for further details.
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=63&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://snap.nlc.dcccd.edu/reference/bash1/features_29.html">http://snap.nlc.dcccd.edu/reference/bash1/features_29.html</a> has a bash-specific technique for processing calculations:</p>
<pre>
$[ expression ]
$(( expression ))
</pre>
<p>See the link for further details.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nixshell.wordpress.com/63/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nixshell.wordpress.com/63/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/63/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=63&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2007/09/28/maths-in-bash-shell/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>IFS &#8211; Internal Field Separator</title>
		<link>http://nixshell.wordpress.com/2007/09/26/ifs-internal-field-separator/</link>
		<comments>http://nixshell.wordpress.com/2007/09/26/ifs-internal-field-separator/#comments</comments>
		<pubDate>Wed, 26 Sep 2007 00:41:09 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/09/26/ifs-internal-field-separator/</guid>
		<description><![CDATA[It seems like an esoteric concept, but it&#8217;s actually very useful.
If your input file is &#8220;1 apple steve@example.com&#8221;, then your script could say:
while read qty product customer
do
  echo "${customer} wants ${qty} ${product}(s)"
done
The read command will read in the three variables, because they&#8217;re spaced out from each other.
However, critical data is often presented in spreadsheet [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=62&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>It seems like an esoteric concept, but it&#8217;s actually very useful.</p>
<p>If your input file is &#8220;1 apple steve@example.com&#8221;, then your script could say:</p>
<pre>while read qty product customer
do
  echo "${customer} wants ${qty} ${product}(s)"
done</pre>
<p>The <code>read</code> command will read in the three variables, because they&#8217;re spaced out from each other.</p>
<p>However, critical data is often presented in spreadsheet format. If you save these as CSV files, it will come out like this:</p>
<pre>1,apple,steve@example.com</pre>
<p>This contains no spaces, and the above code will not be able to understand it. It will take the whole thing as one item &#8211; the first thing, quanity, <code>$qty</code>, and set the other two fields as blank.</p>
<p>The way around this, is to tell the entire shell, that &#8220;,&#8221; (the comma itself) separates fields; it&#8217;s the &#8220;internal field separator&#8221;, or IFS.</p>
<p>The IFS variable is set to space/tab/newline, which isn&#8217;t easy to set in the shell, so it&#8217;s best to save the original IFS to another variable, so you can put it back again after you&#8217;ve messed around with it. I tend to use &#8220;<code>oIFS=$IFS</code>&#8221; to save the current value into &#8220;oIFS&#8221;.</p>
<p>Also, when the IFS variable is set to something other than the default, it can really mess with other code.</p>
<p>Here&#8217;s a script I wrote today to parse a CSV file:</p>
<pre>
#!/bin/sh
oIFS=$IFS     # Always keep the original IFS!
IFS=","          # Now set it to what we want the "read" loop to use
while read qty product customer
do
  IFS=$oIFS
  # process the information
  IFS=","       # Put it back to the comma, for the loop to go around again
done &lt; myfile.txt</pre>
<p>It really is that easy, and it&#8217;s very versatile. You do have to be careful to keep a copy of the original (I always use the name oIFS, but whatever suits you), and to put it back as soon as possible, because so many things invisibly use the IFS &#8211; grep, cut, you name it. It&#8217;s surprising how many things within the &#8220;<code>while read</code>&#8221; loop actually did depend on the IFS being the default value.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nixshell.wordpress.com/62/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nixshell.wordpress.com/62/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/62/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=62&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2007/09/26/ifs-internal-field-separator/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Logic</title>
		<link>http://nixshell.wordpress.com/2007/09/07/logic/</link>
		<comments>http://nixshell.wordpress.com/2007/09/07/logic/#comments</comments>
		<pubDate>Fri, 07 Sep 2007 01:00:06 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[MLP]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/09/07/logic/</guid>
		<description><![CDATA[Whilst not directly related to shell programming, understanding of basic logic operations &#8211; AND, OR, NOR, XOR, NAND, etc, are as important to shell programmers as to C, Java, .Net and other coders.
My recent interactive logic gate page seems to have become quite popular; it&#8217;s just a simple implementation of each of the major logic [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=61&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Whilst not directly related to shell programming, understanding of basic logic operations &#8211; AND, OR, NOR, XOR, NAND, etc, are as important to shell programmers as to C, Java, .Net and other coders.</p>
<p>My recent <a href="http://steve-parker.org/logic/">interactive logic gate</a> page seems to have become quite popular; it&#8217;s just a simple implementation of each of the major logic circuits in use. If you want to see more, say so &#8211; I&#8217;ll add anything you ask for <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nixshell.wordpress.com/61/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nixshell.wordpress.com/61/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/61/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=61&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2007/09/07/logic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>25 useful commands in Linux/UNIX for Beginners</title>
		<link>http://nixshell.wordpress.com/2007/08/22/25-useful-commands-in-linuxunix-for-beginners/</link>
		<comments>http://nixshell.wordpress.com/2007/08/22/25-useful-commands-in-linuxunix-for-beginners/#comments</comments>
		<pubDate>Wed, 22 Aug 2007 01:04:03 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[MLP]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/08/22/25-useful-commands-in-linuxunix-for-beginners/</guid>
		<description><![CDATA[The (often a bit geeky for this blog) FreeBSD-World website has a good &#8220;Top-25&#8243; list of 25 useful commands in Linux/UNIX for Beginners (note: new URL updated 31 Aug 2008)
I&#8217;m not sure that #24 (dig) and #25 (host) are absolutely necessary, #18 (startx) is possibly outdated these days, and the compression tools (6-9) are much [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=60&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The (often a bit geeky for this blog) FreeBSD-World website has a good &#8220;Top-25&#8243; list of <a href="http://www.bsdworld.net/story.php?id=15">25 useful commands in Linux/UNIX for Beginners</a> (note: new URL updated 31 Aug 2008)</p>
<p>I&#8217;m not sure that #24 (<code>dig</code>) and #25 (<code>host</code>) are absolutely necessary, #18 (<code>startx</code>) is possibly outdated these days, and the compression tools (6-9) are much of a muchness, but apart from that, #1 &#8211; #23 should be familiar to anyone who claims to be experienced with UNIX/Linux. If somebody was missing one, it would have to be #18 (<code>startx</code>), as (a) it&#8217;s not needed on servers, and (b) modern *nix distros will boot into a GUI automatically when possible.</p>
<p>So what&#8217;s the list?<br />
25. host<br />
24. dig<br />
23. mkdir<br />
22. rm<br />
21. cp<br />
20. grep<br />
19. ls<br />
18. startx<br />
17. nano / vi<br />
16. pwd<br />
15. cat<br />
14. man<br />
13. kill<br />
12. locate<br />
11. ifconfig<br />
10. ssh<br />
9. gzip<br />
8. bzip2<br />
7. zip<br />
6. tar  (I would put 6-9 in one category, personally. rar should probably be in there too)<br />
5. mount<br />
4. passwd<br />
3. ping<br />
2. tail<br />
1. top</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nixshell.wordpress.com/60/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nixshell.wordpress.com/60/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/60/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=60&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2007/08/22/25-useful-commands-in-linuxunix-for-beginners/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>vi</title>
		<link>http://nixshell.wordpress.com/2007/08/01/vi/</link>
		<comments>http://nixshell.wordpress.com/2007/08/01/vi/#comments</comments>
		<pubDate>Wed, 01 Aug 2007 00:40:10 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/08/01/vi/</guid>
		<description><![CDATA[I use vi every day; to me, there is no better text editor. It is apparently a little intimidating for the newcomer, though&#8230;. here&#8217;s a beginner&#8217;s guide to the VI editor.
I would write one of these, but &#8211; much as I love vi, and I really do, everyone who uses vi, seems to have their [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=59&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I use vi every day; to me, there is no better text editor. It is apparently a little intimidating for the newcomer, though&#8230;. here&#8217;s a <a href="http://www-acs.ucsd.edu/info/vi_tutorial.shtml">beginner&#8217;s guide to the VI editor</a>.</p>
<p>I would write one of these, but &#8211; much as I love vi, and I really do, everyone who uses vi, seems to have their own experience of it, and their own shortcuts. We&#8217;ve all got our own quirks. One thing&#8217;s for sure; vi is not notepad!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nixshell.wordpress.com/59/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nixshell.wordpress.com/59/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/59/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=59&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2007/08/01/vi/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Shell Pitfalls</title>
		<link>http://nixshell.wordpress.com/2007/07/30/shell-pitfalls/</link>
		<comments>http://nixshell.wordpress.com/2007/07/30/shell-pitfalls/#comments</comments>
		<pubDate>Mon, 30 Jul 2007 12:40:20 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[MLP]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/07/30/shell-pitfalls/</guid>
		<description><![CDATA[Greg Wooledge has an excellent list of Bash Pitfalls, with good explanations as to why they are wrong, and what the correct syntax should be.
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=58&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Greg Wooledge has an excellent list of <a href="http://wooledge.org/mywiki/BashPitfalls">Bash Pitfalls</a>, with good explanations as to why they are wrong, and what the correct syntax should be.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nixshell.wordpress.com/58/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nixshell.wordpress.com/58/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/58/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=58&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2007/07/30/shell-pitfalls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Understanding init scripts</title>
		<link>http://nixshell.wordpress.com/2007/07/25/understanding-init-scripts/</link>
		<comments>http://nixshell.wordpress.com/2007/07/25/understanding-init-scripts/#comments</comments>
		<pubDate>Wed, 25 Jul 2007 23:47:06 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[init]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/07/25/understanding-init-scripts/</guid>
		<description><![CDATA[UNIX and Linux systems use &#8220;init scripts&#8221; &#8211; scripts typically placed in /etc/init.d/ which are run when the system starts up and shuts down (or changes runlevels, but we won&#8217;t go into that level of detail here, being more of a sysadmin topic than a shell scripting topic). In a typical setup, /etc/init.d/myservice is linked [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=57&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>UNIX and Linux systems use &#8220;init scripts&#8221; &#8211; scripts typically placed in <code>/etc/init.d/</code> which are run when the system starts up and shuts down (or changes runlevels, but we won&#8217;t go into that level of detail here, being more of a sysadmin topic than a shell scripting topic). In a typical setup, <code>/etc/init.d/myservice</code> is linked to <code>/etc/rc2.d/S70myservice</code>. That is to say, <code>/etc/init.d/myservice</code> is the real file, but the <code>rc2.d</code> file is a symbolic link to it, called <code>"S70myservice"</code>. The &#8220;S&#8221; means &#8220;Start&#8221;, and &#8220;70&#8243; says when it should be run &#8211; lower-numbered scripts are run first. The range is usually 1-99, but there are no rules. <code>/etc/rc0.d/K30myservice</code> (for shutdown), or <code>/etc/rc6.d/K30myservice</code> (for reboot; possibly a different scenario for some services), will be the corresponding &#8220;Kill&#8221; scripts. Again, you can control the order in which your services are shut down; K01* first, to K99* last.</p>
<p>All of these rc scripts are just symbolic links to <code>/etc/init.d/myservice</code>, so there is just one actual shell script, which takes care of starting or stopping the service. The Samba init script from Solaris is a nice and simple script to use as an example:</p>
<pre>
case "$1" in
start)
	[ -f /etc/sfw/smb.conf ] || exit 0

	/usr/sfw/sbin/smbd -D
	/usr/sfw/sbin/nmbd -D
	;;
stop)
	pkill smbd
	pkill nmdb
	;;
*)
	echo "Usage: $0 { start | stop }"
	exit 1
	;;
esac
exit 0
</pre>
<p>The <code>init</code> daemon, which controls init scripts, calls a startup script as <code>"/etc/rc2.d/S70myservice start"</code>, and a shutdown script as <code>"/etc/rc0.d/K30myservice stop"</code>. So we have to check the variable <code>$1</code> to see what action we need to take. (See <a href="http://steve-parker.org/sh/variables2.shtml">http://steve-parker.org/sh/variables2.shtml</a> to read about what <code>$1</code> means &#8211; in this case, it&#8217;s either &#8220;start&#8221; or &#8220;stop&#8221;).</p>
<p>So we use <a href="http://steve-parker.org/sh/case.shtml">case</a> (follow link for more detail) to see what we are required to do. </p>
<p>In this example, if it&#8217;s &#8220;start&#8221;, then it will run the three commands:</p>
<pre>
	[ -f /etc/sfw/smb.conf ] || exit 0
	/usr/sfw/sbin/smbd -D
	/usr/sfw/sbin/nmbd -D
</pre>
<p>Where line 1 checks that smb.conf exists; there is no point continuing if it doesn&#8217;t exist, just &#8220;exit 0&#8243; (success) so the system continues booting as normal. Lines 2 and 3 start the two daemons required for Samba.</p>
<p>If it&#8217;s &#8220;stop&#8221;, then it will run these two commands:</p>
<pre>
	pkill smbd
	pkill nmdb
</pre>
<p><code>pkill</code> means &#8220;Process Kill&#8221;, and it simply kills off the two processes started by the &#8220;start&#8221; option.</p>
<p>The <code>"*)"</code> construct catches any other uses, and simply replies that the correct syntax is to call it with either &#8220;start&#8221; or &#8220;stop&#8221; &#8211; nothing else will do. Some services allow for status reports, restarting, and so on. The one thing we do need to provide is &#8220;start&#8221;. Most services also have a &#8220;stop&#8221; function. All others are optional.</p>
<p>The simplest possible init script would be this, to control an Apache webserver:</p>
<pre>
#!/bin/sh
/usr/sbin/apachectl $1
</pre>
<p>Apache comes with a program called &#8220;apachectl&#8221; (or &#8220;apache2ctl&#8221;), which will take &#8220;stop&#8221; and &#8220;start&#8221; as arguments, and act accordingly. It will also take &#8220;restart&#8221;, &#8220;status&#8221;, &#8220;configtest&#8221;, and a few more options, but that one-line script would be enough to act as /etc/init.d/apache, with /etc/rc2.d/S90apache and /etc/rc0.d/K10apache linking to it. To be frank, even that is not necessary; you could just link <code>/usr/sbin/apachectl</code> into <code>/etc/init.d/apache</code>. In reality, it&#8217;s normally good to provide a few sanity-checks in addition to the basic stop/start functionality.</p>
<p>The vast majority of init scripts use the <a href="http://steve-parker.org/sh/case.shtml">case</a> command; around that, you can wrap all sorts of other things &#8211; most GNU/Linux distributions include a generic reporting script (typically <code>/lib/lsb/init-functions</code> &#8211; to report &#8220;OK&#8221; or &#8220;FAILED&#8221;), read in a config file (like the Samba example above), define functions for the more involved aspects of starting, stopping, or reporting on the status of the service, and so on. </p>
<p>Some (eg, SuSE) have an &#8220;INIT INFO&#8221; block, which may allow the <code>init</code> daemon a bit more control over the order in which services are started. Ubuntu&#8217;s <a target="_blank" href="http://upstart.ubuntu.com/">Upstart</a> is another; Solaris 10 uses <a target="_blank" href="http://docs.sun.com/app/docs/doc/819-3055/6n5a6lhji?a=view">pmf</a> (Process Monitor Facility), which starts and stops processes, but also monitors them to check that they are running as expected.</p>
<p>After a good decade of stability, in 2007 the world of init scripts appears to be changing, potentially quite significantly. However, I&#8217;m not here to speculate on future developments, this post is just to document the stable interface which is init scripts. Even if other things change, the basic &#8220;start|stop&#8221; syntax is going to be with us for a long time to come. It is easy, but often important, to understand what is going on.</p>
<p>In closing, I will list the run-levels, and what each run-level provides:</p>
<pre>0: Shut down the OS (without powering off the machine)
1, s, S: Single-User mode. Networking is not enabled.
2: Networking enabled (not NFS, Printers)
3: Normal operating mode (including NFS, Printers)
4: Not normally used
5: Shut down the OS and power off the machine
6: Reboot the OS.</pre>
<p>Some GNU/Linux distributions change these definitions &#8211; in particular, Debian provides all network services at runlevel 2, not 3. Run-level 5 is also sometimes used to start the graphical (X) interface.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nixshell.wordpress.com/57/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nixshell.wordpress.com/57/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/57/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=57&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2007/07/25/understanding-init-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Shell Pipes by Example</title>
		<link>http://nixshell.wordpress.com/2007/07/22/shell-pipes-by-example/</link>
		<comments>http://nixshell.wordpress.com/2007/07/22/shell-pipes-by-example/#comments</comments>
		<pubDate>Sun, 22 Jul 2007 00:54:31 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pipes]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/07/22/shell-pipes-by-example/</guid>
		<description><![CDATA[Pipes, piping, pipelines&#8230; whatever you call them, are very powerful &#8211; in fact, they are one of the core tenets of the philosophy behind UNIX (and therefore Linux).  They are also, really, very simple, once you understand them.  The way to understand them, is by playing with them, but if you don&#8217;t know [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=56&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Pipes, piping, pipelines&#8230; whatever you call them, are very powerful &#8211; in fact, they are one of the core tenets of the philosophy behind UNIX (and therefore Linux).  They are also, really, very simple, <em>once you understand them</em>.  The way to understand them, is by playing with them, but if you don&#8217;t know what they do, you don&#8217;t know where to start&#8230; Catch-22!</p>
<p>So, here are some simple examples of how the pipe works.</p>
<h3>Let&#8217;s see the code</h3>
<p><code>$ grep steve /etc/passwd | cut -d: -f 6<br />
/home/steve<br />
$</code><br />
What did this do? There are two UNIX commands there: <code>grep</code> and <code>cut</code>. The command &#8220;<code>grep steve /etc/passwd</code>&#8221; finds all lines in the file <code>/etc/passwd</code> which contain the text &#8220;steve&#8221; anywhere in the line. In my case, this has one result:<br />
<code>steve:x:1000:1000:Steve Parker,,,:/home/steve:/bin/bash</code><br />
The second command, &#8220;<code>cut -d: -f6</code>&#8221; cuts the line by the delimiter (-d) of a colon (&#8221;<code>:</code>&#8220;), and gets field (-f) number 6. This is, in the <code>/etc/passwd</code> file, the home directory of the user.</p>
<h3>So what? Show me some more</h3>
<p>This is the main point of this article; once you&#8217;ve seen a few examples, it normally all becomes clear.</p>
<h4>EG2</h4>
<pre>$ find . -type f -ls | cut -c14- | sort -n -k 5
rw-r--r--   1 steve    steve       28 Jul 22 01:41 ./hello.txt
rwxr-xr-x   1 steve    steve     6500 Jul 22 01:41 ./a/filefrag
rwxr-xr-x   1 steve    steve     8828 Jul 22 01:42 ./c/hostname
rwxr-xr-x   1 steve    steve    30848 Jul 22 01:42 ./c/ping
rwxr-xr-x   1 steve    steve    77652 Jul 22 01:42 ./b/find
rwxr-xr-x   1 steve    steve    77844 Jul 22 01:41 ./large
rwxr-xr-x   1 steve    steve    93944 Jul 22 01:41 ./a/cpio
rwxr-xr-x   1 steve    steve    96228 Jul 22 01:42 ./b/grep
$</pre>
<p>What I did here, was three commands: &#8220;<code>find . -type f -ls</code>&#8221; finds regular files, and lists them in an &#8220;ls&#8221;-style format: permissions, owner, size, etc.<br />
&#8220;<code>cut -c14-</code>&#8221; cuts out the first 14 characters, which mess up the formatting on this website (!), and aren&#8217;t very interesting.<br />
&#8220;<code>sort -n -k 5</code>&#8221; does a numeric (-n) sort, on field 5 (-k5), which is the size of the file.<br />
So this gives me a list of the files in this directory (and subdirectories), ordered by file size. That&#8217;s much more useful than &#8220;<code>ls -lS</code>&#8220;, which restricts itself to the current directory, but not subdirectories.</p>
<p>(As an aside, I have to admit that I only concocted this by trying to think of an example; it actually seems really useful, and worth making into an alias&#8230; I must do a post about &#8220;<code>alias</code>&#8221; some time!)</p>
<h3>So how does it work?</h3>
<p>This seems pretty straightforward: get lines containing &#8220;steve&#8221; from the input file (&#8221;<code>grep steve /etc/passwd</code>&#8220;), and get the sixth field (where fields are marked by colons) (&#8221;<code>cut -d: -f6</code>&#8220;). You can read the full command from left to right, and see what happens, in that order.</p>
<h3>How does it really work?</h3>
<h4>EG1 Explained</h4>
<p>There are some gotchas when you start to look at the plumbing. Because we&#8217;re using the analogy of a pipe (think of water flowing through a pipe), the OS actually sets up the commands in the reverse order. It calls <code>cut</code>first, then it calls <code>grep</code>. If you have (for example) a syntax error in your <code>cut</code> command, then <code>grep</code> will never be called.<br />
What actually happens is this:</p>
<ol>
<li>A &#8220;pipe&#8221; is set up &#8211; a special entity which can take input, which it passes, line by line, to its output.
<li><code>cut</code> is called, and its input is set to be the &#8220;pipe&#8221;.
<li><code>grep</code> is called, and its output is set to be the &#8220;pipe&#8221;.
<li>As <code>grep</code> generates output, it is passed through the pipe, to the waiting <code>cut</code> command, which does its own simple task, of splitting the fields by colons, and selecting the 6th field as output.</ol>
<h4>EG2 Explained</h4>
<p>For EG2, &#8220;<code>sort</code>&#8221; is called first, which ties to the second (rightmost) pipe for its input. Then &#8220;<code>cut</code>&#8221; is called, which ties to the second pipe for its output, and the first (leftmost) pipe for its input. Then, &#8220;<code>find</code>&#8221; is called, which ties to the first pipe for its output.<br />
So, the output of &#8220;<code>find</code>&#8221; is piped into &#8220;<code>cut</code>&#8220;, which strips off the first 14 characters of the &#8220;<code>find</code>&#8221; output. This is then passed to &#8220;<code>sort</code>&#8220;, which sorts on field 5 (of what it receives as input), so the output of the entire pipeline, is a numerically sorted list of files, ordered by size.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nixshell.wordpress.com/56/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nixshell.wordpress.com/56/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/56/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=56&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2007/07/22/shell-pipes-by-example/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Shell Cheatsheet</title>
		<link>http://nixshell.wordpress.com/2007/07/14/shell-cheatsheet/</link>
		<comments>http://nixshell.wordpress.com/2007/07/14/shell-cheatsheet/#comments</comments>
		<pubDate>Sat, 14 Jul 2007 00:17:40 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/07/14/shell-cheatsheet/</guid>
		<description><![CDATA[There doesn&#8217;t seem to be any decent shell CheatSheet out there, so I have undertaken to write one.
This is my first attempt; once I actually printed it out, I realised that the the font was actually rather large, so I had room to include much more than I had originally sketched out.
Cheatsheet You may notice [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=55&subd=nixshell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>There doesn&#8217;t seem to be any decent shell CheatSheet out there, so I have undertaken to write one.</p>
<p>This is my first attempt; once I actually printed it out, I realised that the the font was actually rather large, so I had room to include much more than I had originally sketched out.</p>
<p><a href="http://steve-parker.org/sh/cheatsheet.pdf">Cheatsheet</a> You may notice that there are a lot of blanks;  <a href="http://steve-parker.org/sh/shell_cheatsheet.pdf">Shell Cheatsheet</a> has the same content, with some ideas for new content. Please tell me what you want to see in there  &#8211; There is still lots of room, it&#8217;s only about 60% full.</p>
<p>What would you fill the other 40% with?</p>
<p>Does this seem to be a useful cribsheet? What would you like to see in it?</p>
<p>Also, what format would you prefer? PDF? PNG? GIF? DOC?!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nixshell.wordpress.com/55/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nixshell.wordpress.com/55/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nixshell.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nixshell.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nixshell.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nixshell.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nixshell.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nixshell.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nixshell.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nixshell.wordpress.com/55/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&blog=691157&post=55&subd=nixshell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2007/07/14/shell-cheatsheet/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
	</channel>
</rss>