Alternative to Get-Content

后端 未结 3 675
再見小時候
再見小時候 2020-12-11 10:40

I currently have the following line of code.

(Get-Content \'file.txt\') |
  ForEach-Object {$_ -replace \'\"\', \'\'} |
  Set-Content \'file.txt\'

3条回答
  •  失恋的感觉
    2020-12-11 11:11

    This should be faster than line-by-line processing, and still keep your memory consumption under control:

    Get-content 'file.txt' -ReadCount 5000 |
     foreach-object {$_ -replace '"', '' | 
     add-content 'newfile.txt' }
    

提交回复
热议问题