Bird
0
0

If text="automation", what does ${text:0:4} return?

easy🧠 Conceptual Q2 of 15
Bash Scripting - String Operations
If text="automation", what does ${text:0:4} return?
A"autoa"
B"toma"
C"auto"
D"tion"
Step-by-Step Solution
Solution:
  1. Step 1: Identify offset and length

    Offset is 0, length is 4, so extract first 4 characters starting at index 0.
  2. Step 2: Extract substring from "automation"

    Characters at positions 0 to 3 are 'a', 'u', 't', 'o' forming "auto".
  3. Final Answer:

    "auto" -> Option C
  4. Quick Check:

    Substring from start with length 4 = "auto" [OK]
Quick Trick: Offset 0 means start; length is how many chars to take [OK]
Common Mistakes:
MISTAKES
  • Starting count at 1 instead of 0
  • Extracting wrong characters
  • Including extra characters beyond length

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes