158k views
5 votes
NO LINKS

write a shell script to find the sum of all integers between 100 and 200 which are divisible by 9​

User Janelly
by
3.7k points

1 Answer

2 votes

Answer:

#!/usr/bin/env bash

for num in {100..200}

do

if [ $((num % 9)) -eq 0 ]

then

((sum += num))

fi

done

echo $sum

Step-by-step explanation:

The output will be 1683.

User Rogervila
by
4.0k points