Here I am going to show you way to read huge files in Windows PowerShell. If you have a large text file, say more than 70 MB, you know how hard it is to open them. Visual Studio, Notepad++ will open them but very slowly and that application will become unresponsive for little time. Imagine if your file much bigger, near GB in size, you get the idea!
We can use Windows PowerShell to open such file, I prefer to select some lines. Command for that is:
# Command-Format: Get-Content 'your-file-path' -Tail <number-of-line>
Get-Content '.\mylargefile.txt' -Tail 5000
This will read the last 5000 lines of this file.
Say, In case you have one large file and it has only one line, then you need to read some character for that file.
In that case, below command is useful:
$bytes = Get-Content '.\largefile.txt' -TotalCount 50000 -Encoding byte
([char[]]($bytes)) -Join '' > outputfile.txt
This command will read 50 thousands character of that file as byte array, then second line converts it to character array and join them again (because each character will be in separate line) and finally write it to a file named “outputfile.txt”.
I will be adding more useful commands like this on this page as i find them.
I have removed this phrase