NOTES
You must complete this project via the JCCC Linux server. Other environments may have different paths, different commands installed, etc which will alter your answers.
Many of these questions are auto-graded by Canvas and must match the Canvas answer(s)
exactly. In particular:
- Capitalization, spelling, and punctuation matter!
- Variable and file names given in the question must match your answer.
- Where white space is required in the answer use only a single space.
- Don't use leading or trailing white space in your answers.
If you feel you've given a correct answer which Canvas marked incorrect contact the instructor.
I strongly suggest you write these on the server and verify they work. Then copy your answers into Canvas. To copy text from the putty window simply highlight it with your mouse.
Flag question: Question 1Question 13 pts
Write a single command that
- Prompts the user to enter the month and day of their birth.
- Reads the values into variables named month and day.
- Allows them no more than 10 seconds to respond.
View keyboard shortcutspView keyboard shortcutsAccessibility Checker20 wordsSwitch to the html editorFullscreenFlag question: Question 2Question 21 ptsWrite a single line that will display the value of positional parameter number 5 to the screen.Flag question: Question 3Question 31 ptsWrite a single line that will display the number of command-line parameters to the screen.Flag question: Question 4Question 43 pts
Complete the script below which displays the sum of all the command-line parameters. You may assume the command line parameters are integers, but you don't know how many integers there will be before the script is run.
#!/bin/bashsum=0# Write the missing portion that goes here.echo $sum
Copy/paste the entire script into the answer box.
View keyboard shortcutspView keyboard shortcutsAccessibility Checker0 wordsSwitch to the html editorFullscreenFlag question: Question 5Question 51 pts
Given the portion of the script somescript below, what would be the output from running: ./somescript -b
while [ -n "$1" ]docase "$1" in-a) echo "1" ;;-b) echo "2" ;;-c) echo "3" ;;*) echo "4" ;;esacshiftdoneFlag question: Question 6Question 61 pts
Given the portion of the script
somescript
below, what would be the output from running:
./somescript -ac
while [ -n "$1" ]docase "$1" in-a) echo "1" ;;-b) echo "2" ;;-c) echo "3" ;;*) echo "4" ;;esacshiftdoneFlag question: Question 7Question 71 pts
What would be the output from the following:
getopt q:rs -sq param -r oParam
View keyboard shortcutspView keyboard shortcutsAccessibility Checker5 wordsSwitch to the html editorFullscreenFlag question: Question 8Question 82 pts
Write a single command that will:
- Process the positional parameters with getopt. Suppress errors and use the optstring q:rs.
- Replace the original positional parameters with the output from getopt.
View keyboard shortcutsEditViewInsertFormatToolsTable12ptParagraphpView keyboard shortcutsAccessibility Checker0 wordsSwitch to the html editorFullscreenFlag question: Question 9Question 92 pts
The script
somescript
contains the code below and has been called this way:
./somescript -sq param -r oParam
The loop has already run twice and displayed the following:
sq
What will the next iteration of the loop display?
while getopts q:rs optdoecho "$opt"done