nerdexam
CompTIA

XK0-006 · Question #126

A systems administrator is developing a script to copy a file if it exists and return an error if it does not. Given the following incomplete script: Which of the following statements is missing…

The correct answer is C. else. An else statement is required to handle the condition when the file does not exist so the script can return the error message instead of attempting the copy operation.

Automation and Scripting

Question

A systems administrator is developing a script to copy a file if it exists and return an error if it does not. Given the following incomplete script:

Which of the following statements is missing from the script?

Exhibit

XK0-006 question #126 exhibit

Options

  • Awhile
  • Bdone
  • Celse
  • Dfor

How the community answered

(23 responses)
  • B
    4% (1)
  • C
    96% (22)

Explanation

An else statement is required to handle the condition when the file does not exist so the script can return the error message instead of attempting the copy operation.

Topics

#bash scripting#conditional logic#if-else#file existence check

Community Discussion

No community discussion yet for this question.

Full XK0-006 Practice