Bird
0
0

Why does this script produce an error?

medium📝 Debug Q7 of 15
Bash Scripting - String Operations
Why does this script produce an error?
echo ${#}
AVariable is unset
BMissing variable name after #
CSyntax is correct, no error
DBraces are not allowed here
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the expression ${#}

    The syntax expects a variable name after the # to get length.
  2. Step 2: Missing variable name causes syntax error

    Without a variable name, bash cannot compute length and throws error.
  3. Final Answer:

    Missing variable name after # -> Option B
  4. Quick Check:

    Variable name required after # in ${#var} [OK]
Quick Trick: Always specify variable name after # in ${#var} [OK]
Common Mistakes:
MISTAKES
  • Leaving variable name empty after #
  • Assuming ${#} returns something valid
  • Forgetting braces around #var

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes