In PowerShell, you can use Select-String
to mimic grep -f
, which matches patterns from a file. Here’s how:
powershell
Select-String -Path "file.txt" -Pattern (Get-Content "patterns.txt")
-Path
: Specifies the file to search (file.txt
).Get-Content
: Reads patterns frompatterns.txt
.-Pattern
: Matches lines based on patterns.
This searches file.txt
for lines matching patterns listed in patterns.txt.