Solved

Linux: Add Strings

Posted on 2013-11-15
3
175 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
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

911 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

17 Experts available now in Live!

Get 1:1 Help Now