<?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: Checking if a variable is a number in ksh</title>
	<atom:link href="http://www.tech-recipes.com/rx/756/checking-if-a-variable-is-a-number-in-ksh/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tech-recipes.com/rx/756/checking-if-a-variable-is-a-number-in-ksh/</link>
	<description>Computer and technology tutorials and guides</description>
	<lastBuildDate>Sun, 22 Nov 2009 03:12:08 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Andrew</title>
		<link>http://www.tech-recipes.com/rx/756/checking-if-a-variable-is-a-number-in-ksh/comment-page-1/#comment-10418</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Wed, 15 Apr 2009 17:28:07 +0000</pubDate>
		<guid isPermaLink="false">guid-fix-me!#comment-10418</guid>
		<description>I&#039;m not sure if anyone will read this, but to check if a variable is a number in ksh, it would take 1 expression, there is no reason to add, subtract or do any arithmetic. Example of a script:&lt;br&gt;&lt;br&gt;G_VAR=$1&lt;br&gt;if [[ $G_VAR = +([0-9]) ]]; then&lt;br&gt;    print &quot;G_VAR is a number&quot;&lt;br&gt;else&lt;br&gt;    print &quot;G_VAR is not a number&quot;&lt;br&gt;fi</description>
		<content:encoded><![CDATA[<p>I&#39;m not sure if anyone will read this, but to check if a variable is a number in ksh, it would take 1 expression, there is no reason to add, subtract or do any arithmetic. Example of a script:</p>
<p>G_VAR=$1<br />if [[ $G_VAR = +([0-9]) ]]; then<br />    print &#8220;G_VAR is a number&#8221;<br />else<br />    print &#8220;G_VAR is not a number&#8221;<br />fi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mr. KIPS</title>
		<link>http://www.tech-recipes.com/rx/756/checking-if-a-variable-is-a-number-in-ksh/comment-page-1/#comment-7152</link>
		<dc:creator>Mr. KIPS</dc:creator>
		<pubDate>Fri, 09 Jan 2009 14:31:11 +0000</pubDate>
		<guid isPermaLink="false">guid-fix-me!#comment-7152</guid>
		<description>I wouldn&#039;t play with the exit status. Instead, change the arithmetic expression. Use expr $1 +1.</description>
		<content:encoded><![CDATA[<p>I wouldn&#39;t play with the exit status. Instead, change the arithmetic expression. Use expr $1 +1.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nacho_a</title>
		<link>http://www.tech-recipes.com/rx/756/checking-if-a-variable-is-a-number-in-ksh/comment-page-1/#comment-3820</link>
		<dc:creator>nacho_a</dc:creator>
		<pubDate>Fri, 03 Oct 2008 06:45:49 +0000</pubDate>
		<guid isPermaLink="false">guid-fix-me!#comment-3820</guid>
		<description>What if $1 is 0?&lt;br&gt;You&#039;ll get FALSE!&lt;br&gt;&lt;br&gt;From expr&#039;s man page:&lt;br&gt;&lt;br&gt;    EXIT STATUS&lt;br&gt;        [...]&lt;br&gt;        0     if the expression is neither NULL nor 0&lt;br&gt;        1     if the expression is either NULL or 0&lt;br&gt;&lt;br&gt;        [...]&lt;br&gt;I&#039;d  use &quot;-eq 2&quot; instead of  &quot;-ne 0.&quot;&lt;br&gt;&lt;br&gt;Thanks anyway, good tip.</description>
		<content:encoded><![CDATA[<p>What if $1 is 0?<br />You&#39;ll get FALSE!</p>
<p>From expr&#39;s man page:</p>
<p>    EXIT STATUS<br />        [...]<br />        0     if the expression is neither NULL nor 0<br />        1     if the expression is either NULL or 0</p>
<p>        [...]<br />I&#39;d  use &#8220;-eq 2&#8243; instead of  &#8220;-ne 0.&#8221;</p>
<p>Thanks anyway, good tip.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
