如何在Windows中分割大文本文件? [英] How to split large text file in windows?

查看:1942
本文介绍了如何在Windows中分割大文本文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大小为2.5 GB的日志文件。是否可以使用Windows命令提示符将此文件拆分为较小的文件?

解决方案

如果已安装


您可以在此图中看到 split 生成的文件被命名为 xaa xab xac 等。


这些名称是由可以指定的前缀和后缀。由于未指定前缀或后缀的外观,因此前缀默认为 x ,后缀默认为两个字符的字母枚举。


另一个示例:


此示例演示了



  • 使用文件名前缀 MySlice (而不是默认的 x ),

  • -d 标志用于使用数字后缀(而不是 aa ab ac 等),

  • 和选项 -a 5 告诉我,我希望后缀为5位数字:



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?

解决方案

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:

这篇关于如何在Windows中分割大文本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆