Bird
0
0

You want to append the line "Backup complete" to backup.log, but your script uses echo "Backup complete" > backup.log. What is the problem?

medium📝 Debug Q14 of 15
Bash Scripting - File Operations in Scripts
You want to append the line "Backup complete" to backup.log, but your script uses echo "Backup complete" > backup.log. What is the problem?
AThe command appends but adds extra blank lines.
BThe command overwrites the file instead of appending.
CThe file <code>backup.log</code> will not be created.
DThe command will cause a syntax error.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the operator used

    The single > operator overwrites the file content, replacing it with new text.
  2. Step 2: Identify correct operator for appending

    To add text without deleting existing content, >> should be used instead.
  3. Final Answer:

    The command overwrites the file instead of appending. -> Option B
  4. Quick Check:

    Use >> to append, not > [OK]
Quick Trick: Use >> to append, > overwrites [OK]
Common Mistakes:
MISTAKES
  • Using > when >> is needed
  • Expecting append but file is replaced
  • Thinking > causes syntax error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes