In a Bash case statement, which value will trigger dothisthing given the pattern 'case matchWord in 1) dothisthing ;; esac'?

Study for the OSCP Linux Exam. Use our flashcards and multiple-choice questions to test your skills. Each query comes with detailed hints and explanations to enhance your preparedness. Get ready to conquer the exam!

Multiple Choice

In a Bash case statement, which value will trigger dothisthing given the pattern 'case matchWord in 1) dothisthing ;; esac'?

Explanation:
The case statement uses pattern matching against the value after case. The pattern here is a literal 1, which means it matches exactly the string "1". Bash compares matchWord as text, not as a number, so dothisthing will run only when matchWord expands to "1". Other values like 0, 2, or 3 do not match this pattern, so they won’t trigger the action. In short, the action fires when the value is exactly 1.

The case statement uses pattern matching against the value after case. The pattern here is a literal 1, which means it matches exactly the string "1". Bash compares matchWord as text, not as a number, so dothisthing will run only when matchWord expands to "1". Other values like 0, 2, or 3 do not match this pattern, so they won’t trigger the action. In short, the action fires when the value is exactly 1.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy