Bird
0
0

What does the command echo "Hello" > file.txt do in Linux?

easy📝 Conceptual Q11 of 15
Linux CLI - Pipes and Redirection
What does the command echo "Hello" > file.txt do in Linux?
AIt writes "Hello" to file.txt, replacing any existing content.
BIt adds "Hello" to the end of file.txt without removing existing content.
CIt displays "Hello" on the screen without saving to a file.
DIt deletes file.txt if it exists.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the > operator

    The > operator redirects output to a file, replacing its content.
  2. Step 2: Analyze the command effect

    echo "Hello" outputs "Hello" and > saves it to file.txt, overwriting old content.
  3. Final Answer:

    It writes "Hello" to file.txt, replacing any existing content. -> Option A
  4. Quick Check:

    > means overwrite file [OK]
Quick Trick: Use > to overwrite file content, >> to append [OK]
Common Mistakes:
  • Confusing > with >> and thinking it appends
  • Believing output only shows on screen
  • Assuming file is deleted

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes