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
  • 30,653
  • 7
  • 76
  • 79

2 Answers2

1
#!/bin/sh
echo "enter the first number"
read a
echo "enter the seconf number"
read b
echo  $(($a+$b))
Eugen Rieck
  • 62,299
  • 10
  • 67
  • 91
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,857
  • 12
  • 10