Bird
0
0

Which of the following is the correct syntax to search for the word 'error' in a file named 'log.txt' using Select-String?

easy📝 Syntax Q12 of 15
PowerShell - String Operations
Which of the following is the correct syntax to search for the word 'error' in a file named 'log.txt' using Select-String?
ASelect-String -Pattern error -Path log.txt
BSelect-String log.txt error
CSelect-String -File log.txt -Search error
DSelect-String -Find error -File log.txt
Step-by-Step Solution
Solution:
  1. Step 1: Recall Select-String parameter names

    The correct parameters are -Pattern for the search text and -Path for the file.
  2. Step 2: Match syntax with options

    Select-String -Pattern error -Path log.txt uses -Pattern and -Path correctly; others use invalid parameters.
  3. Final Answer:

    Select-String -Pattern error -Path log.txt -> Option A
  4. Quick Check:

    Correct parameters = Select-String -Pattern error -Path log.txt [OK]
Quick Trick: Use -Pattern for text and -Path for files [OK]
Common Mistakes:
  • Using incorrect parameter names like -File or -Find
  • Omitting parameter names and causing errors
  • Mixing order of parameters incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes