LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to cut a big file into pieces of a certain size? (https://www.linuxquestions.org/questions/linux-general-1/how-to-cut-a-big-file-into-pieces-of-a-certain-size-381815/)

kornerr 11-10-2005 11:23 AM

How to cut a big file into pieces of a certain size?
 
I want to archive a big file, then cut it to fit several CDs.
Then copy these pieces from CDs, and make these pieces one big file back again.
How can I accomplish it?

Thanks.

kornerr 11-10-2005 11:47 AM

It's probably "split" to cut, and "cat" to merge.

makuyl 11-10-2005 01:28 PM

Perhaps something like:
tar -cvzf - source_file | split -b 700m - tarpiece-
cat tarpiece-* > filename.tar.gz

kornerr 11-10-2005 08:06 PM

Thanks, makuyl.

nappy501 12-29-2005 12:38 PM

Quote:

Originally Posted by makuyl
Perhaps something like:
tar -cvzf - source_file | split -b 700m - tarpiece-
cat tarpiece-* > filename.tar.gz

Hi,
I have been looking for a way to split files. I think the line above may be what I want. If you could clarify for me.

I have a main hard drive and and secondary hard drive. Every so often I back up my home directory with the following ( a friend gave it to me).
su then cd /
tar cvf /mnt/shared/homemonth.tar /home/nappy
This creates a tar file on my second hard drive. I then burn them onto a cd. However the files are now too big to burn onto a cd. My last backup was 906mb. My second hard drive has now run out of space as I have 4.1gb of tar files.

I presume I would have to do the above command and then burn the bits to cd?

I am unclear about the above command and I would like to understand it before I use it. Do I type it as you have written it?

I presume I would type:
tar -cvzf - /home/nappy | split -b 650m - tarpiece-

I have to have all those dashes? Would this then create the bits of the tar file in my home directory, which I could then burn to cd?

Sorry if this sounds really basic:newbie:

Nappy

kornerr 12-29-2005 07:20 PM

First, you'd better back up like this:
Code:

tar -cjf /mnt/shared/home_month.tar.bz2 /home/nappy
That will save your space.
Then you can
Code:

split -b 700m /mnt/shared/home_month.tar.bz2
FYI:
Code:

man split

nappy501 12-31-2005 11:41 AM

Quote:

Originally Posted by kornerr
First, you'd better back up like this:
Code:

tar -cjf /mnt/shared/home_month.tar.bz2 /home/nappy
That will save your space.
Then you can
Code:

split -b 700m /mnt/shared/home_month.tar.bz2
FYI:
Code:

man split

Hi,
Thank you so much for that. It makes more sense to me like that. Command, the size you want and the file to do it to. The tar files are already sitting on my second hard drive.

So I tried it out, took me a while to find the bits. The original file was 906mb. I found the bits called xaa and xab in the root directory. I then burned them to CD.

Just two questions, if I wanted to get the file back, now it is on two cds, what would I do? The second question is can I rename xaa and xab, to something more meaningful. I am being careful to write on all the cd's, but they are all going to have files called xaa and xab.

Regards

Nappy

kornerr 12-31-2005 12:01 PM

Of course, you can rename it. xaa, xab, etc are just parts of the splitted file.
You can merge them back this way:
Code:

cat xa* > my_home_dir.tar.bz2

nappy501 12-31-2005 03:42 PM

Quote:

Originally Posted by kornerr
Of course, you can rename it. xaa, xab, etc are just parts of the splitted file.
You can merge them back this way:
Code:

cat xa* > my_home_dir.tar.bz2

Hi

Thank you very much again. Your explanations have been clear and concise. That's what you need when your a newbie.

Now if I could get you to come around to my house and get my scanner, usb port, card reader and camera to work I'd be well away :D

Happy New Year!

Nappy

Poetics 12-31-2005 03:52 PM

If you check the HCL (link at the top of the page), which stands for "Hardware Compatibility List," for your specific hardware, you'll see the success stories of others and how they got that same hardware to work for them!


All times are GMT -5. The time now is 11:49 PM.