I have a log file with size of 2.5 GB. Is there any way to split this file into smaller files using windows command prompt?
相关问题
- React Native Inline style for multiple Text in sin
- Inheritance impossible in Windows Runtime Componen
- how to get running process information in java?
- Is TWebBrowser dependant on IE version?
- How can I have a python script safely exit itself?
相关文章
- 在vscode如何用code runner打开独立的控制台窗口,以及设置好调试模式时窗口的编码?
- 如何让cmd.exe 执行 UNICODE 文本格式的批处理?
- 怎么把Windows开机按钮通过修改注册表指向我自己的程序
- 放在input的text下文本一直出现一个/(即使还没输入任何值)是什么情况
- Warning : HTML 1300 Navigation occured?
- Bundling the Windows Mono runtime with an applicat
- Windows 8.1 How to fix this obsolete code?
- CosmosDB emulator can't start since port is al
you can split using a third party software http://www.hjsplit.org/, for example give yours input that could be upto 9GB and then split, in my case I split 10 MB each
Of course there is! Win CMD can do a lot more than just split text files :)
Split a text file into separate files of 'max' lines each:
If above code hangs or crashes, this example code splits files faster (by writing data to intermediate files instead of keeping everything in memory):
eg. To split a file with 7,600 lines into smaller files of maximum 3000 lines.
set
command to be fed to/g
flag offindstr
list1.txt
list2.txt
list3.txt
eg. for the 1st file:
Notes:
Works with leading whitespace, blank lines & whitespace lines.
Tested on Win 10 x64 CMD, on 4.4GB text file, 5651982 lines.
If you have installed Git for Windows, you should have Git Bash installed, since that comes with Git.
Use the
split
command in Git Bash to split a file:into files of size 500MB each:
split myLargeFile.txt -b 500m
into files with 10000 lines each:
split myLargeFile.txt -l 10000
Tips:
If you don't have Git/Git Bash, download at https://git-scm.com/download
If you lost the shortcut to Git Bash, you can run it using
C:\Program Files\Git\git-bash.exe
That's it!
I always like examples though...
Example:
You can see in this image that the files generated by
split
are namedxaa
,xab
,xac
, etc.These names are made up of a prefix and a suffix, which you can specify. Since I didn't specify what I want the prefix or suffix to look like, the prefix defaulted to
x
, and the suffix defaulted to a two-character alphabetical enumeration.Another Example:
This example demonstrates
MySlice
(instead of the defaultx
),-d
flag for using numerical suffixes (instead ofaa
,ab
,ac
, etc...),-a 5
to tell it I want the suffixes to be 5 digits long:Cut
Cuts the number of lines from the top or bottom of file.
Example
Another way This outputs lines 5001+, adapt for your use. This uses almost no memory.
You can use the command split for this task. For example this command entered into the command prompt
creates several files with a size of 500 MByte each. This will take several minutes for a file of your size. You can rename the output files (by default called "xaa", "xab",... and so on) to *.txt to open it in the editor of your choice.
Make sure to check the help file for the command. You can also split the log file by number of lines or change the name of your output files.
(tested on Windows 7 64 bit)