<?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 parameter expansion cheatsheet</title>
	<atom:link href="http://www.xaprb.com/blog/2007/03/29/bash-parameter-expansion-cheatsheet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xaprb.com/blog/2007/03/29/bash-parameter-expansion-cheatsheet/</link>
	<description>Stay curious!</description>
	<lastBuildDate>Thu, 09 Feb 2012 09:56:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: find command in unix</title>
		<link>http://www.xaprb.com/blog/2007/03/29/bash-parameter-expansion-cheatsheet/#comment-19457</link>
		<dc:creator>find command in unix</dc:creator>
		<pubDate>Mon, 27 Jun 2011 08:13:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=316#comment-19457</guid>
		<description>Important point to note is that &lt;a href=&quot;http://javarevisited.blogspot.com/2011/06/special-bash-parameters-in-script-linux.html&quot; rel=&quot;nofollow&quot;&gt; $* and $@ bash parameters &lt;/a&gt; behave identical without double quotes but entirely different if used within double quotes. in case of $* individual parameters will be separated by IFS characters while in case of $@ individual parameters will appear in quotes and separated by space.</description>
		<content:encoded><![CDATA[<p>Important point to note is that <a href="http://javarevisited.blogspot.com/2011/06/special-bash-parameters-in-script-linux.html" rel="nofollow"> $* and $@ bash parameters </a> behave identical without double quotes but entirely different if used within double quotes. in case of $* individual parameters will be separated by IFS characters while in case of $@ individual parameters will appear in quotes and separated by space.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith T</title>
		<link>http://www.xaprb.com/blog/2007/03/29/bash-parameter-expansion-cheatsheet/#comment-19174</link>
		<dc:creator>Keith T</dc:creator>
		<pubDate>Wed, 23 Feb 2011 18:45:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=316#comment-19174</guid>
		<description>Using eval and echo you can kludge up nested parameter expansion.

Let&#039;s say you have $param1 and $param2. param1=&quot;Hi&quot; and param2=&quot;There&quot;. You have a routine you want to reuse, wherein all you have to pass it is 1 or 2 and it will use the appropriate $param1 or $param2.

You set INDEX=1 or INDEX=2 depending on which one you want.

&gt; INDEX=1
&gt; echo $(eval echo $(eval &#039;echo \$\{param$INDEX\}&#039;))
Hi
&gt; INDEX=2
&gt; echo $(eval echo $(eval &#039;echo \$\{param$INDEX\}&#039;))
There

It&#039;s convoluted for sure, but it works.</description>
		<content:encoded><![CDATA[<p>Using eval and echo you can kludge up nested parameter expansion.</p>
<p>Let&#8217;s say you have $param1 and $param2. param1=&#8221;Hi&#8221; and param2=&#8221;There&#8221;. You have a routine you want to reuse, wherein all you have to pass it is 1 or 2 and it will use the appropriate $param1 or $param2.</p>
<p>You set INDEX=1 or INDEX=2 depending on which one you want.</p>
<p>&gt; INDEX=1<br />
&gt; echo $(eval echo $(eval &#8216;echo \$\{param$INDEX\}&#8217;))<br />
Hi<br />
&gt; INDEX=2<br />
&gt; echo $(eval echo $(eval &#8216;echo \$\{param$INDEX\}&#8217;))<br />
There</p>
<p>It&#8217;s convoluted for sure, but it works.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: alex5161</title>
		<link>http://www.xaprb.com/blog/2007/03/29/bash-parameter-expansion-cheatsheet/#comment-18991</link>
		<dc:creator>alex5161</dc:creator>
		<pubDate>Tue, 21 Dec 2010 00:37:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=316#comment-18991</guid>
		<description>You have one not completely correct example in the pattern matching:
&quot;
# Oops, I didn&#039;t mean that... get rid of the numbers.
for file in *.gif; do mv $file ${file##[0-9]}; done 
&quot;
 - the ${file##[0-9]} by using &#039;##&#039; should means to remove long matching of number - here that is unappliable:
  if $file is &#039;a555name&#039; - nothing matched, as before number there is something else.
  if $file is &#039;123name&#039; - only first number is matched, while, I guess, assumed to remove &#039;123&#039;: it is not happend, because [0-9] - is one number only.
  To remove &#039;123&#039; it could be ${file#*[0-9]} - no needs for &#039;##&#039;, as it would remove up to any found number in the file name, if the name has it.
 But it is not good enouth, as it, also, would remove &#039;a555&#039; from the &#039;a555name&#039;, that is not planned.
 It should be specified as &#039;any number of diggits from beggining of the variable value&#039;, something like : /^[0-9]+/; but pattern expansion is not accepting such syntax.</description>
		<content:encoded><![CDATA[<p>You have one not completely correct example in the pattern matching:<br />
&#8220;<br />
# Oops, I didn&#8217;t mean that&#8230; get rid of the numbers.<br />
for file in *.gif; do mv $file ${file##[0-9]}; done<br />
&#8220;<br />
 &#8211; the ${file##[0-9]} by using &#8216;##&#8217; should means to remove long matching of number &#8211; here that is unappliable:<br />
  if $file is &#8216;a555name&#8217; &#8211; nothing matched, as before number there is something else.<br />
  if $file is &#8217;123name&#8217; &#8211; only first number is matched, while, I guess, assumed to remove &#8217;123&#8242;: it is not happend, because [0-9] &#8211; is one number only.<br />
  To remove &#8217;123&#8242; it could be ${file#*[0-9]} &#8211; no needs for &#8216;##&#8217;, as it would remove up to any found number in the file name, if the name has it.<br />
 But it is not good enouth, as it, also, would remove &#8216;a555&#8242; from the &#8216;a555name&#8217;, that is not planned.<br />
 It should be specified as &#8216;any number of diggits from beggining of the variable value&#8217;, something like : /^[0-9]+/; but pattern expansion is not accepting such syntax.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: [bash] Parameter expansions &#171; *NIX tricks</title>
		<link>http://www.xaprb.com/blog/2007/03/29/bash-parameter-expansion-cheatsheet/#comment-17084</link>
		<dc:creator>[bash] Parameter expansions &#171; *NIX tricks</dc:creator>
		<pubDate>Thu, 08 Oct 2009 21:13:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=316#comment-17084</guid>
		<description>[...] Reference: Directly copied from here. [...]</description>
		<content:encoded><![CDATA[<p>[...] Reference: Directly copied from here. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xaprb</title>
		<link>http://www.xaprb.com/blog/2007/03/29/bash-parameter-expansion-cheatsheet/#comment-5433</link>
		<dc:creator>Xaprb</dc:creator>
		<pubDate>Sun, 01 Apr 2007 13:11:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=316#comment-5433</guid>
		<description>&lt;p&gt;Thanks for the tip!  I&#039;m currently on an Ubuntu machine and /dev/tcp isn&#039;t enabled so I can&#039;t test it out, but that is neat!&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Thanks for the tip!  I&#8217;m currently on an Ubuntu machine and /dev/tcp isn&#8217;t enabled so I can&#8217;t test it out, but that is neat!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

