LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Expr in Shell (https://www.linuxquestions.org/questions/linux-newbie-8/expr-in-shell-412952/)

mystical_sun2000 02-08-2006 06:56 AM

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.

Nylex 02-08-2006 06:59 AM

You need to use backticks (`), not single quotes (').


All times are GMT -5. The time now is 10:34 AM.