Bird
0
0

What will be the content of log.txt after running this command twice?

medium📝 Command Output Q5 of 15
Linux CLI - Pipes and Redirection
What will be the content of log.txt after running this command twice?
echo "Line" | tee log.txt
Alog.txt contains one line: Line
Blog.txt contains two lines: Line\nLine
Clog.txt is empty
Dlog.txt contains one line: Line\nLine (appended)
Step-by-Step Solution
Solution:
  1. Step 1: Understand tee default behavior

    Without -a, tee overwrites the file each time.
  2. Step 2: Apply to repeated command

    Running twice overwrites log.txt twice, leaving one line "Line".
  3. Final Answer:

    log.txt contains one line: Line -> Option A
  4. Quick Check:

    tee overwrites file by default = log.txt contains one line: Line [OK]
Quick Trick: tee overwrites file unless -a is used [OK]
Common Mistakes:
  • Assuming tee appends by default
  • Confusing tee with >> redirection
  • Expecting multiple lines without -a

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes