Bird
0
0

Identify the error in this script snippet:

medium📝 Debug Q14 of 15
Bash Scripting - Text Processing in Scripts
Identify the error in this script snippet:
read name <<
ANo error, script runs fine
Bread command cannot use here strings
CMissing quotes around John in here string
DIncorrect use of echo syntax
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the here string usage

    The here string operator works with read and does not require quotes for simple alphanumeric strings like John.
  2. Step 2: Check the given snippet

    read name << correctly sets name=John (even with literal \n if present), and echo "Name is $name" outputs correctly. No syntax or runtime errors.
  3. Final Answer:

    No error, script runs fine -> Option A
  4. Quick Check:

    Here strings + read works without quotes for simple input [OK]
Quick Trick: Here strings with read work without quotes for simple input [OK]
Common Mistakes:
MISTAKES
  • Assuming read can't use here strings
  • Thinking quotes are always required
  • Misunderstanding echo syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes