Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Linux: Add Strings

Posted on 2013-11-15
3
Medium Priority
?
188 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 1600 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 400 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

604 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