Solved

Linux: Add Strings

Posted on 2013-11-15
3
174 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
  • 2
3 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 400 total points
Comment Utility
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
Comment Utility
x=1
y=2

echo $((x+y))

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

Expert Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now