When I tried to open 2.5 GB
size text file in Notepad or Notepad ++, I encountered the exception “File is
too big to be opened by Notepad++”
Now, how will we open and read
this big size file. This blog will explain two approach to read the big size
file by using Window PowerShell.
1.
You can simply view
the all file content by using get-content command
PS C:\temp> get-content -path
Sample.txt
You can apply filter on number of records partial view by using –totalCount
option and you can view only first 1000 records.
PS C:\temp> get-content -path
Sample.txt -totalcount 1000
2.
You can import
some segment of file content into another file by using set-content command and
then you will be able to open this file.
PS C:\temp> get-content -path
Sample.txt -totalcount 1000 | set-content
path NewSample.txt
In above command, it imports first 1000 records into file “NewSample.txt”
And also you can skip records while creating new file
PS C:\temp> get-content -path
Sample.txt -totalcount 1000 |
Select-object -skip 100 | set-content path NewSample.txt
In above command, first it skip 100 records and then rest 900 records
will be imported into file “NewSample.txt”