Skip to content

Instantly share code, notes, and snippets.

@deleep000
Created January 2, 2014 21:51
Show Gist options
  • Save deleep000/8227629 to your computer and use it in GitHub Desktop.
Save deleep000/8227629 to your computer and use it in GitHub Desktop.
Powershell command to delete all the lines matching a word from a file.
# PowerShell
Get-Content <sometext_or_log_file> | Where-Object {$_ -notmatch "<exact string>"} | Set-Content <outputfile>
# Example
Get-Content W3000454.log | Where-Object {$_ -notmatch "ping"} | Set-Content c:\log\W3000454_no_ping.log
# The above command will strip all the lines matching the word "ping" and writes to W3000454_no_ping.log
Copy link

ghost commented Nov 6, 2021

thanks dude

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment