LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problem with expr (https://www.linuxquestions.org/questions/linux-newbie-8/problem-with-expr-4175562768/)

arivarasan.e@gmail.com 12-31-2015 12:07 AM

Problem with expr
 
Hi All,
I want to subtract two variables in shellscript. This is what I did:
echo "`expr ${var1} - ${var2}`"
But it throws error saying:
expr: syntax error

Anyone pls tell me the correct syntax for expr.

ardvark71 12-31-2015 12:12 AM

Hi...

Welcome to the forum :)

Just as a suggestion, you might want to contact Jeremy to change your username. Using your e-mail address will most likely result in your inbox being filled with SPAM very soon. ;)

Regards...

arivarasan.e@gmail.com 12-31-2015 04:38 AM

Need to change the userid
 
Hi,
I'm not able to find any option to change the user id in Edit Profile link.. Can u help me pls

ardvark71 12-31-2015 03:00 PM

Quote:

Originally Posted by arivarasan.e@gmail.com (Post 5471276)
Hi,
I'm not able to find any option to change the user id in Edit Profile link.. Can u help me pls

Hi...

There is none. As I mentioned, you will need to contact Jeremy, the forum's owner, to have this changed. ;)

Regards...

TB0ne 12-31-2015 05:41 PM

Quote:

Originally Posted by arivarasan.e@gmail.com (Post 5471212)
Hi All,
I want to subtract two variables in shellscript. This is what I did:
echo "`expr ${var1} - ${var2}`"
But it throws error saying:
expr: syntax error

Anyone pls tell me the correct syntax for expr.

First, read the LQ Rules about text-speak, and about not using it. Spell out your words.

Secondly, there are THOUSANDS of easily-found bash scripting guides that cover this...read the "Question Guidelines" link in my posting signature, and do basic research first, before posting a question. Since you know it's a syntax error, that means that you also know what to look up. An example:
Code:

RESULT=`expr $var1 - $var2`
...from one of the 117,000 hits for "bash script to subtract two variables". Note those are back-ticks, not single-quotes.


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