Monday, October 09, 2006

Split Up a Big Binary or ASCII File and Email

We had to email a 75 megabyte binary file to the states. Unfortunately, the email server doesn't allow for attachments over 10MB. We had to split it up and have it reconstituted at the distant end.

Here is what we did to accomplish this task.

# split -b 5m FileToBeSplit

This instance splits FileToBeSplit into 16X 5MB segments named xaa xab xac...xap.

Now reconstitute at the distant end:

# cat xaa xab xac xad xae xaf xag xah xai xaj xak xal xam xan xao xap > ReconstitutedFile
# cat * > ReconstitutedFile -- ensure xa* are the only files in the directory when using the wildcard

For ASCII files: Split lines -- This example splits a document into 1000 line segments.

# split -l 1000 FileToBeSplit
After this syntax change, the procedures are the same as binary.

--For larger files, find a ftp server or make your filesize increments bigger.


khiork said...

Thank you very much!!! I used you information in this post when migrating from one server to another. It is very useful info.

esofthub said...

Great! I'm glad you found the post useful.

The split command is one of the more useful commands in the UNIX realm IMHO.