What is the output of echo ${hi:-bye} if hi is unset?

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

What is the output of echo ${hi:-bye} if hi is unset?

Explanation:
This tests how Bash handles default values in parameter expansion. The expression ${hi:-bye} means: if hi is set and non-empty, use its value; otherwise use the default word bye. Since hi is unset, the expansion uses the default, and echo prints that value. So the actual output is the string bye (lowercase). The option showing a capitalized Bye is just a capitalization mismatch in the list.

This tests how Bash handles default values in parameter expansion. The expression ${hi:-bye} means: if hi is set and non-empty, use its value; otherwise use the default word bye. Since hi is unset, the expansion uses the default, and echo prints that value. So the actual output is the string bye (lowercase). The option showing a capitalized Bye is just a capitalization mismatch in the list.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy