Bird
0
0

If var="Hello", what will echo ${#var} output?

easy🧠 Conceptual Q2 of 15
Bash Scripting - String Operations
If var="Hello", what will echo ${#var} output?
A0
BHello
C5
D6
Step-by-Step Solution
Solution:
  1. Step 1: Assign the string to variable

    The variable var contains the string "Hello" which has 5 characters.
  2. Step 2: Use ${#var} to get length

    The expression ${#var} returns the number of characters, which is 5.
  3. Final Answer:

    5 -> Option C
  4. Quick Check:

    String length = 5 [OK]
Quick Trick: Count characters to predict ${#var} output [OK]
Common Mistakes:
MISTAKES
  • Counting spaces or adding extra characters
  • Confusing output with the string value
  • Assuming length includes null terminator

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes