Welcome › Forums › General PowerShell Q&A › select-string NOT working
This topic contains 1 reply, has 2 voices, and was last updated by
I am trying to find the 1st occurrence of a string in each file. But it returns ALL the occurrences in each file. What am I doing wrong?
Select-String -Path "c:\downloads\trash\*" -Pattern "aaa"
You're doing nothing wrong. That's what Select-String is made for. If you just want the first match:
Select-String -Path "c:\downloads\trash\*" -Pattern "aaa" | Select-Object -First 1
The topic ‘select-string NOT working’ is closed to new replies.