Bird
0
0

You have a script that sets multiple variables:

hard🚀 Application Q15 of 15
Bash Scripting - Variables
You have a script that sets multiple variables:
var1="one"
var2="two"
var3="three"

You want to unset only variables that start with var and end with an odd number (1 or 3). Which command correctly unsets these variables?
Aunset var1 var2 var3
Bunset var2 var3
Cunset var1 var3
Dunset var2
Step-by-Step Solution
Solution:
  1. Step 1: Identify variables starting with 'var' and ending with odd numbers

    Variables are var1, var2, var3. var1 ends with 1 (odd), var3 ends with 3 (odd), var2 ends with 2 (even).
  2. Step 2: Select variables to unset

    Only var1 and var3 match the pattern, so the command should unset these two.
  3. Final Answer:

    unset var1 var3 -> Option C
  4. Quick Check:

    Unset only odd-ending vars = A [OK]
Quick Trick: Unset only variables matching pattern explicitly [OK]
Common Mistakes:
MISTAKES
  • Unsetting all variables instead of selective ones
  • Confusing odd and even numbers
  • Using unset with variable values instead of names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes