Splitting a file into different size chunks

Amedee Van Gasse (ubuntu) amedee-ubuntu at amedee.be
Tue Mar 31 09:10:12 UTC 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Oliver Marshall schreef:
> Hi chaps,
> 
> I need to split a file in to pieces, but not all of the same size. I
> have a 20mb file, and I need to split the first 2MB in to one file,
> then the following 4MB in to another file, then the next 1MB in to
> another file, and discard the rest.
> 
> Split only splits things in to chunks of the same size. Is there
> another command I can use to create chunks of varying sizes ?
> 
> Olly

I would split the file in 1 MB pieces, and then reassemble my chunks
with cat.

split -d -b 1MB file-to-split temp.
cat temp.00 temp.01 > first-file-2MB
cat temp.02 temp.03 temp.04 temp.05 > second-file-4MB
mv temp.06 third-file-1MB
rm temp.*

I'm sure that there may be better solutions, but this one is simple to
understand and it works.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknR3e8ACgkQxc/p9jmqUL5FCACgvjwl73MnMWA7FKMVwEobeEc3
ng8AoJSCpquSBbIrWTdL/qBVfwIZve1b
=pwpq
-----END PGP SIGNATURE-----




More information about the ubuntu-users mailing list