In sed one can output all matches or e.g. only the first:
$ echo -e 'a1\nb2\nb3'
a1
b2
b3
# print all matches
$ echo -e 'a1\nb2\nb3' | sed -n '/b\(.\)/s//\1/p'
2
3
# print only first match
$ echo -e 'a1\nb2\nb3' | sed -n '0,/b\(.\)/s//\1/p'
2
How can I do this with Powershell?
I get only the first match:
@'
>> a1
>> b2
>> b3
>> '@ | Select-String 'b(.*)' | ForEach-Object{$_.Matches.Groups[1].Value}
2