0

I know it is basic question but i am unable to write simple addition program in unix. i am using cygwin to write the shell script my script is this

#!/bin/sh
echo "enter the first number"
read a
echo "enter the seconf number"
read b
echo  [$a + $b]
Stefano Sanfilippo
  • 32,265
  • 7
  • 79
  • 80

2 Answers2

1
#!/bin/sh
echo "enter the first number"
read a
echo "enter the seconf number"
read b
echo  $(($a+$b))
Eugen Rieck
  • 64,175
  • 10
  • 70
  • 92
0

To add two numbers, you can do this:

let c = $a + $b
echo $c

To read, you can do:

read -p "Enter the first number" a
read -p "Enter the second number" b
Atle
  • 1,867
  • 12
  • 10