Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-08-2006, 06:56 AM   #1
LQ Newbie
Registered: Jun 2005
Location: Mumbai
Distribution: Redhat Linux Advanced Server 2.1
Posts: 7

Rep: Reputation: 0
Expr in Shell

Hi there,

I am creating a shell program. I am using expr but the output is not the one that is expected. This is the code i am trying is

echo "adding two numbers"
echo "Enter First Number"
read a
echo "Enter second Number"
read b
echo "The sum of $a and $b is 'expr $a + $b'"

but instead of giving me the total of two numbers, its giving me the output as "The sum of 2 and 3 is 'expr 2 + 3'". Please help.
Old 02-08-2006, 06:59 AM   #2
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
You need to use backticks (`), not single quotes (').


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
About how to use expr naihe2010 Programming 2 10-31-2005 06:28 AM
expr syntax error baosheng Programming 4 06-09-2005 03:32 PM
simple expr izza_azhar Programming 3 01-17-2005 07:38 PM
Usage of 'expr' command subu_s Programming 2 12-03-2004 01:23 AM
EXPR in shell pragti Programming 3 07-21-2004 03:54 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:37 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration