.net - Reading multiple text lines from a file as stream -


i need read , process large text file in powershell able using following pattern. reading line line seems inefficient me.

$reader = [system.io.file]::opentext($file) while(!$reader.endofstream){  $line = $reader.readline()  ###do } 

so instead of reading line line, possible read multiple lines in 1 go kind of stream object?

why not use built-in command this:

get-content $file -readcount 1024 | foreach {$_} | {$_ -match 'pattern'} 

this reads 1024 lines @ time. run through foreach command flatten array of 1024 lines single lines processing - in case, filtering based on regex pattern.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -