Last active
September 16, 2025 09:07
-
-
Save eugrus/2edb0a37587dd3f5025245e2c31394a6 to your computer and use it in GitHub Desktop.
basically grep -ni or findstr /N /I in PowerShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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