How To Split Large Text File In Windows

Example: If you have a log file with a size of 2.5 GB. and you’re willing to split this file into smaller files using the Windows command prompt? then follow the method:

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 named xaa, 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

  • using a filename prefix of MySlice (instead of the default x),
  • the -d flag for using numerical suffixes (instead of aa, ab, ac, etc…),
  • and the option -a 5 to tell it I want the suffixes to be 5 digits long:

Happy learning!

3 Likes

For less tech savy

3 Likes