Bird
0
0

Identify the error in this script snippet:

medium📝 Debug Q6 of 15
Bash Scripting - File Operations in Scripts
Identify the error in this script snippet:
while read line; do echo $line; done file.txt
AMissing input redirection operator '<' before file.txt
BIncorrect variable name used
CEcho command syntax is wrong
DLoop syntax is invalid
Step-by-Step Solution
Solution:
  1. Step 1: Check how file input is provided

    The script lacks '<' to redirect file.txt as input to the loop.
  2. Step 2: Confirm other parts are correct

    Variable and echo syntax are valid; loop syntax is correct.
  3. Final Answer:

    Missing input redirection operator '<' before file.txt -> Option A
  4. Quick Check:

    Input redirection missing = D [OK]
Quick Trick: Use '< filename' to feed file lines into while read [OK]
Common Mistakes:
MISTAKES
  • Omitting '<' causes error
  • Misusing variable names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes