Bird
0
0

What will be the output of this command if the file 'notes.txt' contains the line 'PowerShell is fun'?

medium📝 Command Output Q13 of 15
PowerShell - String Operations
What will be the output of this command if the file 'notes.txt' contains the line 'PowerShell is fun'?
Select-String -Pattern 'fun' -Path notes.txt
AError: Pattern not found
BPowerShell is fun
CNo output
Dnotes.txt:1:PowerShell is fun
Step-by-Step Solution
Solution:
  1. Step 1: Understand Select-String output format

    Select-String outputs the file name, line number, and matching line by default.
  2. Step 2: Match output with file content

    The line contains 'fun', so output shows 'notes.txt:1:PowerShell is fun'.
  3. Final Answer:

    notes.txt:1:PowerShell is fun -> Option D
  4. Quick Check:

    Output includes filename and line = notes.txt:1:PowerShell is fun [OK]
Quick Trick: Select-String shows filename:line#:matched text [OK]
Common Mistakes:
  • Expecting only matched text without filename
  • Assuming no output if pattern is found
  • Confusing output with error messages

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes