Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need Help in Bash please ______________________________________________________________________ TASK Create a bash script to accomplish the following items. NOTE you use a different function to handle each
Need Help in Bash please
______________________________________________________________________
TASK Create a bash script to accomplish the following items. NOTE you use a different function to handle each of the three valid command-line arguments. Process all arguments passed to the script: 1. Display a usage message if any option other than -j. -p or -r is passed a. Usage: FirstnameLastname_HW4.sh (-il l-p] [-r] i. Should include a short description of what option does 2. If the -j option is passed to your script, tell a joke using a while loop. Use a CASE statement to process the response a. Pete, Pete and Repeat went out on the lake in their boat. Pete and Pete fell out. Who is left in the boat? i. If the user answers "Repeat" or "repeat" then tell the joke again (hint: what does [Rrjepeat do?) If the user answers "Quit" or "quit" then display the message "Goodbye, thank you for playing" and then be done with the joke ili. If the user answers anything else, then display the message "Ok, try and pay attention this time." And then tell the joke again. 3. If the -p option is passed to the script, loop through all of the files in the current directory using a for loop, and a. List out the name of the file b. If the file is a jpeg file (caution - don't use file extension to determine this), then also display the message "This is a photo. You should consider it for your Christmas card." C. If it isn't a jpeg, display the message "Sorry, not a photo. Keep looking." 4. If the -r option is passed to the script, take the user on a "drunk walk" also known as a "random walk" using an "until" loop. a. Initiate a variable to the value 50,000. b. Display the current value and prompt the user to see if he/she wants to go up or down. Use a CASE statement to process the response 1. If the user responds "up" then add a random number (using $RANDOM) ii. If the user responds "quit" then exit the loop iii. If the user responds "down" then subtract a random number iv. For all other input, give the user a message telling them to choose up, quit or down v. Exit the loop when one of the following occurs 1 The user chooses "quit or 2 The number is greater than 100000 or 3 The number is less than 100Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started