b5media.com

Advertise with us

Enjoying this blog? Check out the rest of the Technology Channel Subscribe to this Feed

New Linux User

Split a large file into several smaller files

by Kyle on March 3rd, 2007

Occasionally I have had various files (usually log files) that are so large they can’t be opened using a normal text editor. This usually happens when the log file is in excess of 2GB. The good news is you can split extremely large files using the terminal with the “split” command.

split -bytes=1m /path/to/large/file /prefix/for/smaller/files

You can change the output size by changing -bytes. You can use b, k, or m for bytes, kilobytes, and megabytes, respectively.

If you would like to combine the smaller files back into the larger file, use the “cat” command.

cat smallerFilesPrefix* > LARGEFILENAME

POSTED IN: General, How To

2 opinions for Split a large file into several smaller files

  • ernieofori
    Mar 15, 2007 at 2:08 pm

    hi does split/cat work for binaries?

  • Mark
    May 1, 2008 at 10:00 am

    Thanks for the commands! I just got your code to work, but had to make a small adjustment to it. Here’s the original:

    split -bytes=1m /path/to/large/file /prefix/for/smaller/files

    It should have *two* hyphens before the word “bytes” (or if only one hyphen, just use the letter “b” instead of the full word “bytes”). So corrected, it would read:

    split –bytes=1m /path/to/large/file /prefix/for/smaller/files

    or:

    split -b=1m /path/to/large/file /prefix/for/smaller/files

    Again, thanks for relaying the commands… this is very handy for me right now, as I have to back up a 5.5 GB virtual Windows install to an external drive formatted as vFAT, so it has a 4 GB filesize limit. The “split” command has made 3 smaller chunks which I’ll now copy to my drive with the legacy filesystem.

Have an opinion? Leave a comment:




Check Spelling
Activate Spell Check while Typing