LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 02-08-2006, 07:56 AM   #1
mystical_sun2000
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

#!/bin/bash
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, 07:59 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

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


Reply


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 07:28 AM
expr syntax error baosheng Programming 4 06-09-2005 04:32 PM
simple expr izza_azhar Programming 3 01-17-2005 08:38 PM
Usage of 'expr' command subu_s Programming 2 12-03-2004 02:23 AM
EXPR in shell pragti Programming 3 07-21-2004 04:54 PM


All times are GMT -5. The time now is 08:20 AM.

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