This is a shell script using git bash. would like to replace the while loop with for loop or to use function.
This is a shell script using git bash. would like to replace the while loop with for loop or to use function.
echo "---------------------------------------"
echo "..........Task 1........."
echo "---------------------------------------"
echo;echo
echo "Enter you name: "
read name
echo -n " WELCOME!!! $name"
echo;echo
#Display to get the user input for number for which multiples are to be found
echo "Enter the number to find multiples:"
read num
#Display the minimum and maximum value of range
echo "Enter the minimum and maximum range of values to display: "
read min max
#initializing i to minimum value
echo
i=$min
#initialize 0 to index
count=0
#looping from minimum to maximum values given by the user
echo "Multiples of $num in the given range [$min,$max]: "
while [ $i -le $max ]
do
#checking if i value is divisible by the number
if(($i % $num == 0))
then
if(( $i % 2 == 0 ))
then
echo "$i"
((count++))
#display the multiples in given range
fi fi
((i++))
done
echo "Count of multiples from $min to $max is $count"
#display the count of multiples in the given range
echo "Thank you"
![O MINGW64:/c/Users/tafad/files
tafad@MARISA MINGW64 ~/files
$ ./task1.sh
Task 1...
Enter you name:
WELCOME !!! T
Enter the number to find multiples:
7
Enter the minimum and maximum range of values to display:
15 60
Multiples of 7 in the given range [15,60]:
28
42
56
Count of multiples from 15 to 60 is 3
Thank you
tafad@MARISA MINGW64 ~/files
$ |](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ff08c272d-6d5e-40bf-9093-99a5e11b9860%2F816da977-b066-4f04-957e-26684cbb5c28%2F1zozxm_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 4 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)