Home > bash > Split a large file

Split a large file

Problem

You have a large file and you want to split it up in several pieces of the same size.

Solution

Let’s say we want pieces of 50,000,000 bytes (50 MB approximately).

split --bytes=50000000 film.avi

By default, the output files are named as ‘xaa‘, ‘xab‘, ‘xac‘, etc., where ‘x‘ is the prefix and ‘aa‘, ‘ab‘, ‘ac‘, etc. are the suffixes.

Use the command cat to put them together:

cat xaa xab xac >out.avi

Or simply:

cat x* >out.avi

Variation:

split --bytes=50000000 -d film.avi pre-

Now the pieces will be named as pre-01, pre-02, etc. The switch -d means to use numeric suffixes.

One more:

split --bytes=50m -d film.avi pre-

Now the size of the output pieces is really 50 MB, i.e. 52,428,800 bytes.

Advertisements
Categories: bash Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: