How to split large files in small parts
When one have an 8GB data and wants to break the data in smaller parts than the following method can be used.
Using split & cat command we
can easily do this:
Let say you have an image & its too
big (10 MB). All I do is :
split --bytes=1M
/path/to/image/image.jpg /path/to/image/ prefixForNewImagePieces
To put it together use cat:
cat prefixFiles* > newimage.jpg
Assuming that you are inside the folder where the
image is:
split --bytes=1M myimage.jpg new
If the image is inside a directory
called images you can also do this:
split --bytes=1M images/myimage.jpg
new
If the image is inside the
directory/home/cyrex/images you can do this :
split --bytes=1M
/home/cyrex/images/myimage.jpg new
(In all the cases above it will split
myimage.jpg in 1MB pieces & prefix the name of the pieces with
the word new. So they would look like newaa, newab, newac,
newad.....)
If you are splitting a text file &
want to split it by lines you can do this:
split -l 1000 book.txt new
Than merge them:
cat new* > newimage.jpg
You can even change
the size of the split pieces. Just change the part that says
--bytes=1M to --bytes=1K
for 1kilobyte or 1G for giga, or another number like --bytes=4K
for 4KB pieces.
0 comments:
Post a Comment