Skip to content

Instantly share code, notes, and snippets.

@eugrus
Last active September 16, 2025 09:07
Show Gist options
  • Select an option

  • Save eugrus/2edb0a37587dd3f5025245e2c31394a6 to your computer and use it in GitHub Desktop.

Select an option

Save eugrus/2edb0a37587dd3f5025245e2c31394a6 to your computer and use it in GitHub Desktop.
basically grep -ni or findstr /N /I in PowerShell
param (
[string]$Pattern,
[string]$Path
)
if (-not (Test-Path $Path)) {
Write-Error "File '$Path' not found."
exit 1
}
Get-Content $Path | Select-String -Pattern $Pattern | ForEach-Object {
"$($_.LineNumber): $($_.Line)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment