Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有可能在 100 次匹配后退出 Select-String 以便在文本文件结束之前不必读取?
我想获得一个只有前 100 个匹配的匹配样本。
有没有办法做到这一点?
尝试这个。您可能可以使用 Do-Until 循环或 for 循环并增加一个计数器,然后在达到所需数字后中断循环。
$q = Get-Content 'C:\docs\qqq.txt' $q | Select-String -Pattern "(Patching)" | Select -first 100