|
Re: Searching large text files Thanks Keith. That's what I thought Where-Object would do --filter one
object at a time-- but when the objects are sent through the pipeline from
Get-Content with the -ReadCount parameter set to other than 0 or 1, lines
are skipped.
Try this, it's pretty simple, ten lines, but the Count varies instead of
constantly being 10:
@'
a
ab
abc
abcd
abcde
abcdef
abcdefg
abcdefgh
abcdefghi
abcdefghij
'@ > test.txt
gc test.txt
(gc test.txt -read 1 | ? {$_ -like '*a*'} | mo).count
(gc test.txt -read 2 | ? {$_ -like '*a*'} | mo).count
(gc test.txt -read 3 | ? {$_ -like '*a*'} | mo).count
(gc test.txt -read 4 | ? {$_ -like '*a*'} | mo).count
(gc test.txt -read 5 | ? {$_ -like '*a*'} | mo).count
(gc test.txt -read 6 | ? {$_ -like '*a*'} | mo).count
(gc test.txt -read 7 | ? {$_ -like '*a*'} | mo).count
(gc test.txt -read 8 | ? {$_ -like '*a*'} | mo).count
(gc test.txt -read 9 | ? {$_ -like '*a*'} | mo).count
(gc test.txt -read 10 | ? {$_ -like '*a*'} | mo).count
(gc test.txt -read 1 | ? {$_ -match 'a'} | mo).count
(gc test.txt -read 2 | ? {$_ -match 'a'} | mo).count
(gc test.txt -read 3 | ? {$_ -match 'a'} | mo).count
(gc test.txt -read 4 | ? {$_ -match 'a'} | mo).count
(gc test.txt -read 5 | ? {$_ -match 'a'} | mo).count
(gc test.txt -read 6 | ? {$_ -match 'a'} | mo).count
(gc test.txt -read 7 | ? {$_ -match 'a'} | mo).count
(gc test.txt -read 8 | ? {$_ -match 'a'} | mo).count
(gc test.txt -read 9 | ? {$_ -match 'a'} | mo).count
(gc test.txt -read 10 | ? {$_ -match 'a'} | mo).count
# delete when done
ri test.txt--
Kiron |