<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Simple Maths in the Unix Shell</title>
	<atom:link href="http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/feed/" rel="self" type="application/rss+xml" />
	<link>http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/</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>Sun, 31 Mar 2013 18:54:44 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: unixshell</title>
		<link>http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5946</link>
		<dc:creator><![CDATA[unixshell]]></dc:creator>
		<pubDate>Sun, 31 Mar 2013 18:54:44 +0000</pubDate>
		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5946</guid>
		<description><![CDATA[Oh - and it&#039;s the same backtick at both sides:
x=`expr 20 + 30`
rather than
x=&#039;expr 20 + 30`]]></description>
		<content:encoded><![CDATA[<p>Oh &#8211; and it&#8217;s the same backtick at both sides:<br />
x=`expr 20 + 30`<br />
rather than<br />
x=&#8217;expr 20 + 30`</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: unixshell</title>
		<link>http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5945</link>
		<dc:creator><![CDATA[unixshell]]></dc:creator>
		<pubDate>Sun, 31 Mar 2013 18:53:41 +0000</pubDate>
		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5945</guid>
		<description><![CDATA[@sam - you&#039;ll need spaces around the arguments to expr:
x=`expr 20 + 30`
rather than
x=`expr 20+30`
Also, no need for semicolons to end statements, and of course you&#039;ll need to close the quote on the first echo statement.
Once that&#039;s done, you should get &quot;50&quot; as the answer!]]></description>
		<content:encoded><![CDATA[<p>@sam &#8211; you&#8217;ll need spaces around the arguments to expr:<br />
x=`expr 20 + 30`<br />
rather than<br />
x=`expr 20+30`<br />
Also, no need for semicolons to end statements, and of course you&#8217;ll need to close the quote on the first echo statement.<br />
Once that&#8217;s done, you should get &#8220;50&#8243; as the answer!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sam</title>
		<link>http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5944</link>
		<dc:creator><![CDATA[sam]]></dc:creator>
		<pubDate>Sun, 31 Mar 2013 13:37:56 +0000</pubDate>
		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5944</guid>
		<description><![CDATA[echo &quot;The sum is
x=&#039;expr 20+30&#039; ;
echo $x;
output??]]></description>
		<content:encoded><![CDATA[<p>echo &#8220;The sum is<br />
x=&#8217;expr 20+30&#8242; ;<br />
echo $x;<br />
output??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mahender</title>
		<link>http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5919</link>
		<dc:creator><![CDATA[Mahender]]></dc:creator>
		<pubDate>Tue, 15 Jan 2013 23:18:48 +0000</pubDate>
		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5919</guid>
		<description><![CDATA[Thanks for sharing this, very good inputs. Mahender &lt;a href=&quot;http://etllabs.com/unix/&quot; rel=&quot;nofollow&quot;&gt;UNIX Labs  &lt;/a&gt;]]></description>
		<content:encoded><![CDATA[<p>Thanks for sharing this, very good inputs. Mahender <a href="http://etllabs.com/unix/" rel="nofollow">UNIX Labs  </a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: swathi @ unix scripts forum</title>
		<link>http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5786</link>
		<dc:creator><![CDATA[swathi @ unix scripts forum]]></dc:creator>
		<pubDate>Thu, 11 Oct 2012 11:46:36 +0000</pubDate>
		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5786</guid>
		<description><![CDATA[Thanks for this useful article. For more details on bc and expr commands check the following links:
&lt;a href=&quot;http://www.folkstalk.com/2012/09/bc-command-examples-in-unix-linux.html&quot; rel=&quot;nofollow&quot;&gt;bc command examples in unix&lt;/a&gt;
&lt;a href=&quot;http://www.folkstalk.com/2012/09/expr-command-examples-in-unix-linux.html&quot; rel=&quot;nofollow&quot;&gt;expr command examples in unix&lt;/a&gt;]]></description>
		<content:encoded><![CDATA[<p>Thanks for this useful article. For more details on bc and expr commands check the following links:<br />
<a href="http://www.folkstalk.com/2012/09/bc-command-examples-in-unix-linux.html" rel="nofollow">bc command examples in unix</a><br />
<a href="http://www.folkstalk.com/2012/09/expr-command-examples-in-unix-linux.html" rel="nofollow">expr command examples in unix</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jani "robsku" Saksa</title>
		<link>http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5590</link>
		<dc:creator><![CDATA[Jani "robsku" Saksa]]></dc:creator>
		<pubDate>Sat, 25 Feb 2012 03:25:04 +0000</pubDate>
		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5590</guid>
		<description><![CDATA[And scripts made for bash should use #!/bin/bash , NOT #!/bin/sh anyway :)

To make sure your script is compatible with *pure* bourne shell - if you don&#039;t actually have it (not available for Linux it seems) you might want to grab source code of Heirloom Bourne Shell, compile and install it - also comes with nice man page where you can easily check what is possible with it and then if not sure you can view if something you have used to in bash is possible - the man page is much shorter and easier to read than bash man page as the features are SO much more limited :)]]></description>
		<content:encoded><![CDATA[<p>And scripts made for bash should use #!/bin/bash , NOT #!/bin/sh anyway <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>To make sure your script is compatible with *pure* bourne shell &#8211; if you don&#8217;t actually have it (not available for Linux it seems) you might want to grab source code of Heirloom Bourne Shell, compile and install it &#8211; also comes with nice man page where you can easily check what is possible with it and then if not sure you can view if something you have used to in bash is possible &#8211; the man page is much shorter and easier to read than bash man page as the features are SO much more limited <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 2010 in review &#171; *nix Shell</title>
		<link>http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5377</link>
		<dc:creator><![CDATA[2010 in review &#171; *nix Shell]]></dc:creator>
		<pubDate>Sun, 02 Jan 2011 12:12:50 +0000</pubDate>
		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5377</guid>
		<description><![CDATA[[...] The busiest day of the year was November 9th with 142 views. The most popular post that day was Simple Maths in the Unix Shell. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] The busiest day of the year was November 9th with 142 views. The most popular post that day was Simple Maths in the Unix Shell. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Parker</title>
		<link>http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5324</link>
		<dc:creator><![CDATA[Steve Parker]]></dc:creator>
		<pubDate>Tue, 24 Aug 2010 15:24:11 +0000</pubDate>
		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5324</guid>
		<description><![CDATA[Hi Kumar,

Remove the spaces around the &quot;=&quot; sign:
s=`expr $x + $y`
instead of
s = `expr $x + $y`

Syntactically, the shell thinks that the latter is a request to run a command called &quot;s&quot; with parameters &quot;=&quot; and &quot;`expr $x + $y`&quot;]]></description>
		<content:encoded><![CDATA[<p>Hi Kumar,</p>
<p>Remove the spaces around the &#8220;=&#8221; sign:<br />
s=`expr $x + $y`<br />
instead of<br />
s = `expr $x + $y`</p>
<p>Syntactically, the shell thinks that the latter is a request to run a command called &#8220;s&#8221; with parameters &#8220;=&#8221; and &#8220;`expr $x + $y`&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kumar</title>
		<link>http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5323</link>
		<dc:creator><![CDATA[Kumar]]></dc:creator>
		<pubDate>Tue, 24 Aug 2010 13:59:49 +0000</pubDate>
		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5323</guid>
		<description><![CDATA[Hi, am just a novice shell learner. can anyone explain wats wrong with the below script,

#!/bin/ksh

echo &quot;enter input1:&quot;
read x;
echo &quot;Enter input2:&quot;
read y;


s = `expr $x + $y`
echo &quot;the sum is: $s&quot;


wen i execute its giving the below error msg:

&quot;./dynamic_var.ksh[9]: s:  not found.
the sum is:&quot;


i am not aware wats happenin..! Plzz help me out..???]]></description>
		<content:encoded><![CDATA[<p>Hi, am just a novice shell learner. can anyone explain wats wrong with the below script,</p>
<p>#!/bin/ksh</p>
<p>echo &#8220;enter input1:&#8221;<br />
read x;<br />
echo &#8220;Enter input2:&#8221;<br />
read y;</p>
<p>s = `expr $x + $y`<br />
echo &#8220;the sum is: $s&#8221;</p>
<p>wen i execute its giving the below error msg:</p>
<p>&#8220;./dynamic_var.ksh[9]: s:  not found.<br />
the sum is:&#8221;</p>
<p>i am not aware wats happenin..! Plzz help me out..???</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Commandes Unix &#171; Francesco&#8217;s FAQ</title>
		<link>http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5257</link>
		<dc:creator><![CDATA[Commandes Unix &#171; Francesco&#8217;s FAQ]]></dc:creator>
		<pubDate>Tue, 26 May 2009 13:30:55 +0000</pubDate>
		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5257</guid>
		<description><![CDATA[[...] -pour faire des math dans une shell : ici [...]]]></description>
		<content:encoded><![CDATA[<p>[...] -pour faire des math dans une shell : ici [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: unixshell</title>
		<link>http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5234</link>
		<dc:creator><![CDATA[unixshell]]></dc:creator>
		<pubDate>Mon, 26 Jan 2009 17:04:46 +0000</pubDate>
		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5234</guid>
		<description><![CDATA[That works with Bash (possibly ksh too, can&#039;t remember off the top of my head) but it doesn&#039;t work with the original Bourne shell, nor with dash (which looks likely to replace bash as the default root shell in many upcoming Linux distro&#039;s).

Using bash-specific stuff is fine, if we are sure of having bash installed; if not, then we need to be more generic in our approach :-(]]></description>
		<content:encoded><![CDATA[<p>That works with Bash (possibly ksh too, can&#8217;t remember off the top of my head) but it doesn&#8217;t work with the original Bourne shell, nor with dash (which looks likely to replace bash as the default root shell in many upcoming Linux distro&#8217;s).</p>
<p>Using bash-specific stuff is fine, if we are sure of having bash installed; if not, then we need to be more generic in our approach <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ddouthitt</title>
		<link>http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5233</link>
		<dc:creator><![CDATA[ddouthitt]]></dc:creator>
		<pubDate>Mon, 26 Jan 2009 16:20:42 +0000</pubDate>
		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5233</guid>
		<description><![CDATA[I&#039;m surprised no one mentioned the real solution to shell math.  Using the above example:

a=1
b=2
c=3
d=$(( $a + $b $c ))
echo &quot;$d&quot;

unlike expr, dc, and bc, this requires nothing more than the shell, and requires no exec calls (and no binaries to be read in from disk).]]></description>
		<content:encoded><![CDATA[<p>I&#8217;m surprised no one mentioned the real solution to shell math.  Using the above example:</p>
<p>a=1<br />
b=2<br />
c=3<br />
d=$(( $a + $b $c ))<br />
echo &#8220;$d&#8221;</p>
<p>unlike expr, dc, and bc, this requires nothing more than the shell, and requires no exec calls (and no binaries to be read in from disk).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: unixshell</title>
		<link>http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-3004</link>
		<dc:creator><![CDATA[unixshell]]></dc:creator>
		<pubDate>Mon, 03 Sep 2007 13:37:42 +0000</pubDate>
		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-3004</guid>
		<description><![CDATA[We dont&#039; use set in Bourne, so replace that line with this:

d=`expr $a + $b + $c`

Should work fine.]]></description>
		<content:encoded><![CDATA[<p>We dont&#8217; use set in Bourne, so replace that line with this:</p>
<p>d=`expr $a + $b + $c`</p>
<p>Should work fine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: muralee</title>
		<link>http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-3000</link>
		<dc:creator><![CDATA[muralee]]></dc:creator>
		<pubDate>Mon, 03 Sep 2007 12:40:11 +0000</pubDate>
		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-3000</guid>
		<description><![CDATA[why the below code does not work

a=1
b=2
c=3
set d=`expr [[$a + $b] + $c ]`
echo &quot;$d&quot;

what is the fix req.]]></description>
		<content:encoded><![CDATA[<p>why the below code does not work</p>
<p>a=1<br />
b=2<br />
c=3<br />
set d=`expr [[$a + $b] + $c ]`<br />
echo &#8220;$d&#8221;</p>
<p>what is the fix req.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: More maths stuff - bc in detail &#171; *nix Shell</title>
		<link>http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-134</link>
		<dc:creator><![CDATA[More maths stuff - bc in detail &#171; *nix Shell]]></dc:creator>
		<pubDate>Sun, 08 Apr 2007 00:22:36 +0000</pubDate>
		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-134</guid>
		<description><![CDATA[[...]  There&#8217;s a great post about bc at basicallytech.com - I think that I&#8217;ve already covered most of the same ground, but it&#8217;s got lots of great [...]]]></description>
		<content:encoded><![CDATA[<p>[...]  There&#8217;s a great post about bc at basicallytech.com &#8211; I think that I&#8217;ve already covered most of the same ground, but it&#8217;s got lots of great [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: unixshell</title>
		<link>http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-77</link>
		<dc:creator><![CDATA[unixshell]]></dc:creator>
		<pubDate>Mon, 26 Mar 2007 23:26:34 +0000</pubDate>
		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-77</guid>
		<description><![CDATA[Updating again... I&#039;ve done another, related post, here: http://nixshell.wordpress.com/2007/03/26/calculating-averages/

It deals specifically with averages, but there is more detail about bc, also.]]></description>
		<content:encoded><![CDATA[<p>Updating again&#8230; I&#8217;ve done another, related post, here: <a href="http://nixshell.wordpress.com/2007/03/26/calculating-averages/" rel="nofollow">http://nixshell.wordpress.com/2007/03/26/calculating-averages/</a></p>
<p>It deals specifically with averages, but there is more detail about bc, also.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Calculating Averages &#171; *nix Shell</title>
		<link>http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-74</link>
		<dc:creator><![CDATA[Calculating Averages &#171; *nix Shell]]></dc:creator>
		<pubDate>Mon, 26 Mar 2007 22:30:42 +0000</pubDate>
		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-74</guid>
		<description><![CDATA[[...]  The Simple Maths post seems to be the most popular article in the so-far short life of this [...]]]></description>
		<content:encoded><![CDATA[<p>[...]  The Simple Maths post seems to be the most popular article in the so-far short life of this [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: unixshell</title>
		<link>http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5</link>
		<dc:creator><![CDATA[unixshell]]></dc:creator>
		<pubDate>Tue, 30 Jan 2007 01:19:48 +0000</pubDate>
		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-5</guid>
		<description><![CDATA[bc is indeed far more powerful than expr. Both are rather awkward, though, with their own quirks. I guess if I&#039;m that upset, I should fix it instead of griping about it. It&#039;s been over a decade since I studied Finite State Machines (FSMs) and the like, so I&#039;m probably not the person to provide the ultra-powerful shell-maths tool. There is certainly a need for one, so any students out there looking for a PhD thesis... this could be an idea!]]></description>
		<content:encoded><![CDATA[<p>bc is indeed far more powerful than expr. Both are rather awkward, though, with their own quirks. I guess if I&#8217;m that upset, I should fix it instead of griping about it. It&#8217;s been over a decade since I studied Finite State Machines (FSMs) and the like, so I&#8217;m probably not the person to provide the ultra-powerful shell-maths tool. There is certainly a need for one, so any students out there looking for a PhD thesis&#8230; this could be an idea!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Constantin</title>
		<link>http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-4</link>
		<dc:creator><![CDATA[Constantin]]></dc:creator>
		<pubDate>Mon, 29 Jan 2007 14:20:27 +0000</pubDate>
		<guid isPermaLink="false">http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/#comment-4</guid>
		<description><![CDATA[bc is great because it supports long numbers (as long as you want) and arbitrary precision (set with scale=100 e.g. for 100 decimal places). It can also do trigonometric math and other stuff, if you load it with the math library (bc -l). But I didn&#039;t know how to use it non-interactively / from shell scripts. Thanks!]]></description>
		<content:encoded><![CDATA[<p>bc is great because it supports long numbers (as long as you want) and arbitrary precision (set with scale=100 e.g. for 100 decimal places). It can also do trigonometric math and other stuff, if you load it with the math library (bc -l). But I didn&#8217;t know how to use it non-interactively / from shell scripts. Thanks!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
