[英]How to group powershell select-string output based on filename
I'm using the following Powershell command... not an expert at all, so willing to try different ways.我正在使用以下 Powershell 命令......根本不是专家,所以愿意尝试不同的方式。
select-string -path *.html -pattern $pattern -allmatches |
foreach-object {write-host $_.filename; $_.matches} |
foreach-object {$_.groups[1].value}
I would like to group all of the matches belonging to a file like我想对属于一个文件的所有匹配项进行分组,例如
filename.html
match
match
filename2.html
match
and so on...等等...
Can I do this using the approach above, if so, how?我可以使用上面的方法做到这一点,如果可以,怎么做? If not, could you suggest a better way?
如果没有,你能推荐一个更好的方法吗?
Thank you!谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.