Hello, Please write a Linux BASH script based upon the following instructions. F
ID: 3871448 • Letter: H
Question
Hello,
Please write a Linux BASH script based upon the following instructions.
For this script create a menu that allows the user to select a predetermined location or opt to enter their own location. Then use a CASE Statement to execute the user's choice. Use the following guidelines to write the script:
Name The Script: my_weather
Echo Out The Following Menu To The User
Create a CASE Statement that takes in the users selection as the main input. Depending on the user's
selection, use the following to create the code blocks
Make a default block that alerts the user that they have made an invalid selection
Make A Selection To View The Forecast 1) Northridge, CA 2) New York, New York 3) Paris, France 4) View The Forecast For Another Lpcation Using The Zip Code Enter Your Selection [1-4]:Explanation / Answer
echo -e "Make a selection to view the forecast "
echo -e "1.Northridge,CA "
echo -e "2.New york,New York "
echo -e "3.Paris,France "
echo -e "4.View the forecast for another location using zip code "
read option #Take options from keyboard
echo -e " "
case $option in #Case Statement begins
1)echo -e "curl wttr.in/northridge_california";; #All the options should end with ";;"
2)echo -e "curl wttr.in/newyork";;
3)echo -e "curl wttr.in/paris_france";;
4)echo -e "Please Enter the zip code "
read zip_code
echo -e " "
echo -e "curl wttr.in/$zip_code " ;;
*)echo -e "Please enter the option between [1-4] only ";; #Pressed anything apart from 1-4 options
esac
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.