Shell Functions  «Prev  Next»
 

Shell Script Function Syntax - Quiz

Each question is worth one point. Select the best answer or answers for each question.
1. Which of the following are valid reasons to include a function in a shell script? Please select all the correct answers.
  A. Scripts will be easier to read.
  B. Scripts will take less time to debug.
  C. Scripts will run faster.
  D. Scripts will be more secure.

2. The set of commands inside a function should be surrounded with which set of characters? Please select the best answer.
  A. ( and )
  B. { and }
  C. “ and “
  D. [ and ]

3. Below is a sample function which prints a warning message. Which line(s) contain errors?
1 print_warning {}

2 {

3   echo “This script modifies the volleylist file”

4   echo Be cautious when running this script”

5 }
Please select all the correct answers.
  A. Line 1
  B. Line 2
  C. Line 3
  D. Line 4
  E. Line 5