Bird
0
0

What will be the result of this command?

medium📝 Command Output Q5 of 15
PowerShell - File and Directory Operations
What will be the result of this command?
"Hello" | Out-File -FilePath greetings.txt -Append
"World" | Out-File -FilePath greetings.txt -Append
AFile contains 'HelloWorld' on one line
BFile contains only 'World'
CFile contains 'Hello' and 'World' on separate lines
DCommand throws an error
Step-by-Step Solution
Solution:
  1. Step 1: Understand Out-File with -Append

    Each command appends a line to the file.
  2. Step 2: Output lines are separate

    Out-File adds newlines, so file has two lines: 'Hello' and 'World'.
  3. Final Answer:

    File contains 'Hello' and 'World' on separate lines -> Option C
  4. Quick Check:

    Out-File -Append adds lines separately [OK]
Quick Trick: Out-File -Append adds new lines, not concatenation [OK]
Common Mistakes:
  • Expecting concatenated single line
  • Thinking file is overwritten
  • Confusing Out-File with Set-Content

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes