Solved

Linux: Add Strings

Posted on 2013-11-15
3
184 Views
Last Modified: 2013-11-15
How can I add x and y?  This does not work:
x=1;y=2;echo $x+$y

Open in new window

0
Comment
Question by:hankknight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 400 total points
ID: 39651054
POSIX format:

echo $((x+y))

The old "expr" style:

echo `expr $x + $y`

Using the calculator "bc":

 echo "$x + $y" | bc
0
 
LVL 13

Assisted Solution

by:duncanb7
duncanb7 earned 100 total points
ID: 39651056
x=1
y=2

echo $((x+y))

it should be with $(( ...))
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 39651066
woolmilkporc, you are faster than me in 17 seconds to get the final answer,
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question