<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Bash Shell Functions Tutorial with 6 Practical Examples</title>
	<atom:link href="http://www.thegeekstuff.com/2010/04/unix-bash-function-examples/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thegeekstuff.com/2010/04/unix-bash-function-examples/</link>
	<description>Guides, HowTos and Tips for Technology Geeks</description>
	<lastBuildDate>Thu, 09 Feb 2012 11:52:28 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Bash Shell Expansion Tutorial: 6 Examples of Expanding Expressions within Braces</title>
		<link>http://www.thegeekstuff.com/2010/04/unix-bash-function-examples/comment-page-1/#comment-49292</link>
		<dc:creator>Bash Shell Expansion Tutorial: 6 Examples of Expanding Expressions within Braces</dc:creator>
		<pubDate>Mon, 07 Jun 2010 06:03:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=4012#comment-49292</guid>
		<description>[...] refer to our earlier article on bash shell functions for additional [...]</description>
		<content:encoded><![CDATA[<p>[...] refer to our earlier article on bash shell functions for additional [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zartan</title>
		<link>http://www.thegeekstuff.com/2010/04/unix-bash-function-examples/comment-page-1/#comment-44518</link>
		<dc:creator>Zartan</dc:creator>
		<pubDate>Mon, 26 Apr 2010 20:21:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=4012#comment-44518</guid>
		<description>Sigh.  I forgot to redirect dd&#039;s statistics on stderr.  Try this:

dd if=/dev/urandom bs=$(expr 4 \* $len) count=1 2&gt; /dev/null &#124; tr -cd ‘[:graph:]‘ &#124; head -c $len</description>
		<content:encoded><![CDATA[<p>Sigh.  I forgot to redirect dd&#8217;s statistics on stderr.  Try this:</p>
<p>dd if=/dev/urandom bs=$(expr 4 \* $len) count=1 2&gt; /dev/null | tr -cd ‘[:graph:]‘ | head -c $len</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zartan</title>
		<link>http://www.thegeekstuff.com/2010/04/unix-bash-function-examples/comment-page-1/#comment-44516</link>
		<dc:creator>Zartan</dc:creator>
		<pubDate>Mon, 26 Apr 2010 20:19:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=4012#comment-44516</guid>
		<description>I suspect the author is using /dev/urandom instead of /dev/random because cat will try to fill an entire stdio buffer before passing it on to tr.  Even a 4K buffer would easily empty /dev/random&#039;s entropy pool, then hang waiting for more.  Using &quot;cat -u&quot; would work better, but still would read too much.

Better to limit the amount read by using dd.  Since tr is discarding characters outside the printable ASCII character set, get four times as many as needed:

len=${1:-12}
if [ &quot;0$len&quot; -le 1 ]
then
   len=12
fi
dd if=/dev/urandom bs=$(expr 4 \* $len) count=1 &#124; tr -cd &#039;[:graph:]&#039; &#124; head -c $len
}</description>
		<content:encoded><![CDATA[<p>I suspect the author is using /dev/urandom instead of /dev/random because cat will try to fill an entire stdio buffer before passing it on to tr.  Even a 4K buffer would easily empty /dev/random&#8217;s entropy pool, then hang waiting for more.  Using &#8220;cat -u&#8221; would work better, but still would read too much.</p>
<p>Better to limit the amount read by using dd.  Since tr is discarding characters outside the printable ASCII character set, get four times as many as needed:</p>
<p>len=${1:-12}<br />
if [ "0$len" -le 1 ]<br />
then<br />
   len=12<br />
fi<br />
dd if=/dev/urandom bs=$(expr 4 \* $len) count=1 | tr -cd &#8216;[:graph:]&#8216; | head -c $len<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris F.A. Johnson</title>
		<link>http://www.thegeekstuff.com/2010/04/unix-bash-function-examples/comment-page-1/#comment-44406</link>
		<dc:creator>Chris F.A. Johnson</dc:creator>
		<pubDate>Mon, 26 Apr 2010 00:04:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=4012#comment-44406</guid>
		<description>@gus3, why would anyone use syntax that is more verbose and less useful than the standard syntax, which works perfectly well in bash -- and all other Bourne-type shells?</description>
		<content:encoded><![CDATA[<p>@gus3, why would anyone use syntax that is more verbose and less useful than the standard syntax, which works perfectly well in bash &#8212; and all other Bourne-type shells?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: The Hulk</title>
		<link>http://www.thegeekstuff.com/2010/04/unix-bash-function-examples/comment-page-1/#comment-44397</link>
		<dc:creator>The Hulk</dc:creator>
		<pubDate>Sun, 25 Apr 2010 21:13:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=4012#comment-44397</guid>
		<description>This is one of the greatest sites on the web (for Linux-heads).</description>
		<content:encoded><![CDATA[<p>This is one of the greatest sites on the web (for Linux-heads).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: don taber</title>
		<link>http://www.thegeekstuff.com/2010/04/unix-bash-function-examples/comment-page-1/#comment-44169</link>
		<dc:creator>don taber</dc:creator>
		<pubDate>Sat, 24 Apr 2010 14:23:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=4012#comment-44169</guid>
		<description>My favorite is a floating point version of expr that can handle math &amp; trig functions.  It fires off Perl for each instance so it is not something you&#039;d use where speed is a concern.

fpexpr () 
{ 
    echo &quot;$*&quot; &#124; perl -ne &#039;use Math::Trig; print eval($_),&quot;\n&quot; ;&#039;
}</description>
		<content:encoded><![CDATA[<p>My favorite is a floating point version of expr that can handle math &amp; trig functions.  It fires off Perl for each instance so it is not something you&#8217;d use where speed is a concern.</p>
<p>fpexpr ()<br />
{<br />
    echo &#8220;$*&#8221; | perl -ne &#8216;use Math::Trig; print eval($_),&#8221;\n&#8221; ;&#8217;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gus3</title>
		<link>http://www.thegeekstuff.com/2010/04/unix-bash-function-examples/comment-page-1/#comment-44062</link>
		<dc:creator>gus3</dc:creator>
		<pubDate>Fri, 23 Apr 2010 21:18:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=4012#comment-44062</guid>
		<description>@Chris Johnson: Bash-only syntax is to be expected in an article titled, &quot;Bash Shell Functions...&quot;

@Alpha: Using /dev/urandom does not deplete the entropy pool for services which need real randomness (such as SSL/TLS encryption negotiation). &quot;Strong password&quot; does not automatically equal &quot;entropy&quot;. An example would be taking the phrase &quot;I Love Lucy&quot; and turning it into &quot;;L0v3Loos3e&quot;. It is a strong password, with all four character types (upper- and lower-case, digits, and punctuation), but it is hardly random.</description>
		<content:encoded><![CDATA[<p>@Chris Johnson: Bash-only syntax is to be expected in an article titled, &#8220;Bash Shell Functions&#8230;&#8221;</p>
<p>@Alpha: Using /dev/urandom does not deplete the entropy pool for services which need real randomness (such as SSL/TLS encryption negotiation). &#8220;Strong password&#8221; does not automatically equal &#8220;entropy&#8221;. An example would be taking the phrase &#8220;I Love Lucy&#8221; and turning it into &#8220;;L0v3Loos3e&#8221;. It is a strong password, with all four character types (upper- and lower-case, digits, and punctuation), but it is hardly random.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rubem</title>
		<link>http://www.thegeekstuff.com/2010/04/unix-bash-function-examples/comment-page-1/#comment-43917</link>
		<dc:creator>Rubem</dc:creator>
		<pubDate>Thu, 22 Apr 2010 18:18:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=4012#comment-43917</guid>
		<description>I think it&#039;s great article.
Please. I wondering why anyone talk about PAM autentication? Publish something about it. at a same quality of present article.</description>
		<content:encoded><![CDATA[<p>I think it&#8217;s great article.<br />
Please. I wondering why anyone talk about PAM autentication? Publish something about it. at a same quality of present article.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alpha</title>
		<link>http://www.thegeekstuff.com/2010/04/unix-bash-function-examples/comment-page-1/#comment-43812</link>
		<dc:creator>Alpha</dc:creator>
		<pubDate>Wed, 21 Apr 2010 19:39:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=4012#comment-43812</guid>
		<description>re: Example 3. Bash Function to generate random password

I was wondering why using /dev/random instead of /dev/urandom 
FAILS -- although the former seems more secure,
according to:
http://en.wikipedia.org/wiki//dev/random

Thanks kindly for your reply.</description>
		<content:encoded><![CDATA[<p>re: Example 3. Bash Function to generate random password</p>
<p>I was wondering why using /dev/random instead of /dev/urandom<br />
FAILS &#8212; although the former seems more secure,<br />
according to:<br />
<a href="http://en.wikipedia.org/wiki//dev/random" rel="nofollow">http://en.wikipedia.org/wiki//dev/random</a></p>
<p>Thanks kindly for your reply.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris F.A. Johnson</title>
		<link>http://www.thegeekstuff.com/2010/04/unix-bash-function-examples/comment-page-1/#comment-43802</link>
		<dc:creator>Chris F.A. Johnson</dc:creator>
		<pubDate>Wed, 21 Apr 2010 14:17:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=4012#comment-43802</guid>
		<description>The syntax you use to define functions is a bash-only hybrid. The standard syntax (which will work in all Bourne-type shells) is:

function_name() COMPOUND_COMMAND [optional redirection]

The KornShell syntax (which does not work in all shells) is:

function function_name COMPOUND_COMMAND [optional redirection]</description>
		<content:encoded><![CDATA[<p>The syntax you use to define functions is a bash-only hybrid. The standard syntax (which will work in all Bourne-type shells) is:</p>
<p>function_name() COMPOUND_COMMAND [optional redirection]</p>
<p>The KornShell syntax (which does not work in all shells) is:</p>
<p>function function_name COMPOUND_COMMAND [optional redirection]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Content Delivery Network via Amazon Web Services: CloudFront: static.thegeekstuff.com

Served from: www.thegeekstuff.com @ 2012-02-09 12:20:17 -->
