PowerShell: Extracting certain lines in any file

28 10 2011

I had quite a large file that I needed to parse, and the challenge was to extract certain lines that didn’t match a certain condition.  The solution . . . PowerShell, like so:

select-string -path filename -notmatch "criteria" | foreach {$_.line} | out-file -filepath filename -encoding ascii

That’s it!


Actions

Informations

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>