Bird
0
0

Why does this script fail?

medium📝 Debug Q7 of 15
Bash Scripting - Text Processing in Scripts
Why does this script fail?
cat <
But this works:
cat <<-EOF
	Hello
	World
EOF
ASecond script quotes the delimiter
BFirst script has trailing spaces after EOF
CFirst script uses wrong delimiter spelling
DSecond script uses <<- which strips leading tabs
Step-by-Step Solution
Solution:
  1. Step 1: Understand <<- operator effect

    The <<- operator strips leading tabs from here document lines, allowing indented input.
  2. Step 2: Reason about failure

    The first script fails if lines have tabs but delimiter is <<, which does not strip tabs, causing mismatch.
  3. Final Answer:

    Second script uses <<- which strips leading tabs -> Option D
  4. Quick Check:

    <<- strips tabs, fixing indentation issues [OK]
Quick Trick: Use <<- to allow indented here document content [OK]
Common Mistakes:
MISTAKES
  • Not using <<- for indented content
  • Misunderstanding delimiter role
  • Expecting automatic tab removal

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes