Bird
0
0

Find the error in this script:

medium📝 Debug Q7 of 15
Bash Scripting - User Input
Find the error in this script:
read a b c
 echo "$a $b $c"
User inputs: one two three four
AExtra input words are ignored silently
Bread command cannot handle more than 3 inputs
CVariable c gets 'three four' but echo is missing quotes
DNo error, script works fine
Step-by-Step Solution
Solution:
  1. Step 1: Understand read behavior with extra input

    read assigns first two words to a and b, remaining words to c.
  2. Step 2: Check echo command

    Echo uses quotes, so all variables print correctly.
  3. Final Answer:

    No error, script works fine -> Option D
  4. Quick Check:

    read handles extra input by assigning leftovers to last variable [OK]
Quick Trick: Last variable gets all leftover input words [OK]
Common Mistakes:
MISTAKES
  • Thinking extra input causes error
  • Assuming echo needs changes
  • Ignoring leftover input behavior

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes