How do you sum in bash?
Answer
If you want the user to input the number as an argument to the script, you can use the script below: #!/bin/bash number=”$1″ default=10
sum =`echo “$number + $default” | bc` echo “The sum of $number and 10 is $sum.” Check: ./temp.sh 50 The sum of 50 and 10 is 60.
Answer
If you want the user to input the number as an argument to the script, you can use the script below: #!/bin/bash number=”$1″ default=10
sum =`echo “$number + $default” | bc` echo “The sum of $number and 10 is $sum.” Check: ./temp.sh 50 The sum of 50 and 10 is 60.