<?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>Fri, 10 Feb 2012 12:22:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Virtual_path</title>
		<link>http://www.tech-recipes.com/rx/756/checking-if-a-variable-is-a-number-in-ksh/comment-page-1/#comment-33632</link>
		<dc:creator>Virtual_path</dc:creator>
		<pubDate>Wed, 20 Jul 2011 02:28:00 +0000</pubDate>
		<guid isPermaLink="false">guid-fix-me!#comment-33632</guid>
		<description>Works Great. 
Thanks</description>
		<content:encoded><![CDATA[<p>Works Great.<br />
Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: murph</title>
		<link>http://www.tech-recipes.com/rx/756/checking-if-a-variable-is-a-number-in-ksh/comment-page-1/#comment-40758</link>
		<dc:creator>murph</dc:creator>
		<pubDate>Fri, 16 Jul 2010 15:00:00 +0000</pubDate>
		<guid isPermaLink="false">guid-fix-me!#comment-40758</guid>
		<description>Perfect.</description>
		<content:encoded><![CDATA[<p>Perfect.</p>
]]></content:encoded>
	</item>
	<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-29410</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Wed, 15 Apr 2009 19:28:00 +0000</pubDate>
		<guid isPermaLink="false">guid-fix-me!#comment-29410</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:

G_VAR=$1
if [[ $G_VAR = +([0-9]) ]]; then
    print &quot;G_VAR is a number&quot;
else
    print &quot;G_VAR is not a number&quot;
fi
</description>
		<content:encoded><![CDATA[<p>I&#8217;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-26894</link>
		<dc:creator>Mr. KIPS</dc:creator>
		<pubDate>Fri, 09 Jan 2009 17:31:00 +0000</pubDate>
		<guid isPermaLink="false">guid-fix-me!#comment-26894</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&#8217;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-23837</link>
		<dc:creator>nacho_a</dc:creator>
		<pubDate>Fri, 03 Oct 2008 08:45:00 +0000</pubDate>
		<guid isPermaLink="false">guid-fix-me!#comment-23837</guid>
		<description>What if $1 is 0?
You&#039;ll get FALSE!

From expr&#039;s man page:

    EXIT STATUS
        [...]
        0     if the expression is neither NULL nor 0
        1     if the expression is either NULL or 0

        [...]
I&#039;d  use &quot;-eq 2&quot; instead of  &quot;-ne 0.&quot;

Thanks anyway, good tip.</description>
		<content:encoded><![CDATA[<p>What if $1 is 0?<br />
You&#8217;ll get FALSE!</p>
<p>From expr&#8217;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&#8217;d  use &#8220;-eq 2&#8243; instead of  &#8220;-ne 0.&#8221;</p>
<p>Thanks anyway, good tip.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached (User agent is rejected)
Database Caching 2/12 queries in 0.764 seconds using memcached
Object Caching 326/329 objects using memcached

Served from: www.tech-recipes.com @ 2012-02-10 06:49:41 -->
