PowerShell 等效于 grep -f [英] PowerShell equivalent to grep -f

查看:20
本文介绍了PowerShell 等效于 grep -f的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找与 grep --file=filename 等效的 PowerShell.如果你不知道 grep,filename 是一个文本文件,其中每一行都有一个你想要匹配的正则表达式模式.

I'm looking for the PowerShell equivalent to grep --file=filename. If you don't know grep, filename is a text file where each line has a regular expression pattern you want to match.

也许我遗漏了一些明显的东西,但 Select-String 似乎没有这个选项.

Maybe I'm missing something obvious, but Select-String doesn't seem to have this option.

推荐答案

Select-String 中的 -Pattern 参数支持模式数组.所以你要找的是:

The -Pattern parameter in Select-String supports an array of patterns. So the one you're looking for is:

Get-Content .doc.txt | Select-String -Pattern (Get-Content .
egex.txt)

这通过使用 regex.txt

这篇关于PowerShell 等效于 grep -f的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆