Skip to content

Instantly share code, notes, and snippets.

@markbosky
Last active February 27, 2025 05:18
Show Gist options
  • Save markbosky/e1046f61d6db49928ff202f5a6a3a82d to your computer and use it in GitHub Desktop.
Save markbosky/e1046f61d6db49928ff202f5a6a3a82d to your computer and use it in GitHub Desktop.
Quick Commands For Searching Strings Across Text Files (Powershell)
#Powershell
Get-ChildItem -Path . -Recurse -Filter *.txt | Select-String -Pattern "whatever/.com" | ForEach-Object { "$($_.Path): Line $($_.LineNumber): $($_.Line)`n" } |
Out-File -FilePath results.txt
Get-ChildItem -Path . -Recurse -Filter *.txt | Select-String -Pattern "\@whatever\.com" | ForEach-Object { "$($_.Path): Line $($_.LineNumber): $($_.Line)`n" } | Out-File -FilePath "results_$(Get-Date -Format 'yyyy-MM-dd_HH-mm-ss').txt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment