Bird
0
0

Given the file content of data.txt is initially empty, what will be the content of data.txt after running these commands in order?

medium📝 Command Output Q13 of 15
Linux CLI - Pipes and Redirection
Given the file content of data.txt is initially empty, what will be the content of data.txt after running these commands in order?
echo "First" > data.txt
echo "Second" >> data.txt
echo "Third" > data.txt
AThird
BFirst\nSecond
CSecond\nThird
DFirst\nSecond\nThird
Step-by-Step Solution
Solution:
  1. Step 1: Analyze first command

    echo "First" > data.txt writes "First" to data.txt, replacing any content.
  2. Step 2: Analyze second command

    echo "Second" >> data.txt appends "Second" after "First".
  3. Step 3: Analyze third command

    echo "Third" > data.txt overwrites entire file with "Third" only.
  4. Final Answer:

    Third -> Option A
  5. Quick Check:

    Last > overwrites file content [OK]
Quick Trick: Last > overwrites file, ignoring previous appends [OK]
Common Mistakes:
  • Thinking >> always appends without overwrite
  • Assuming all lines remain after last >
  • Confusing ">" and ">>" effects

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes