1819681 Members
3658 Online
109605 Solutions
New Discussion юеВ

Split files using tar

 
SOLVED
Go to solution
Karthik S S
Honored Contributor

Split files using tar

Is there a way to split a larger file into multiple chunks using tar??

-Karthik S S
For a list of all the ways technology has failed to improve the quality of life, please press three. - Alice Kahn
10 REPLIES 10
Mark Grant
Honored Contributor

Re: Split files using tar

Nope but you could use "split"
Never preceed any demonstration with anything more predictive than "watch this"
Jeff Schussele
Honored Contributor

Re: Split files using tar

Hi Karthik,

Or "csplit"

Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Sanjay Kumar Suri
Honored Contributor

Re: Split files using tar

I have not come across.

tar xvf then split.

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Elmar P. Kolkman
Honored Contributor

Re: Split files using tar

GNU tar can do it, but the HP-UX version doesn't. You could use the split command in combination with tar. Or, a rather dirty solution, create a small lvol, the size you want the tar files to be, and tar to that lvol. When it is full, it will request a new 'tape', copy your data from the lvol to a file and continue the tar to the lvol.

(I haven't tried this, but it should work).
Every problem has at least one solution. Only some solutions are harder to find.
Lorenzo Facello
Valued Contributor

Re: Split files using tar

try to use tar and split commands together.
ex
tar xvf xxx.tar | split -b...


split recognizes the following command-line options and arguments:

-l line_count The input file is split into pieces line_count
lines in size.

-a suffix_length
suffix_length letters are used to form the suffix
of the output filenames. This option allows
creation of more than 676 output files. The
output file names created cannot exceed the
maximum file name length allowed in the directory
containing the files.

-b n The input file is split into pieces n bytes in
size.

-b nk The input file is split into pieces n x 1024 bytes
in size. No space separates the n from the k.

-b nm The input file is split into pieces n x 1048576
bytes in size. No space separates the n from the
m.

-n The input file is split into pieces n lines in
size. This option is obsolescent and is
equivalent to using the -l line_count option.
Elmar P. Kolkman
Honored Contributor

Re: Split files using tar

The example is wrong, the idea correct:
tar cf - | split ...
Every problem has at least one solution. Only some solutions are harder to find.
Umapathy S
Honored Contributor
Solution

Re: Split files using tar

Karthik,

The ideas are the same. You can tar and gzip the file. Then use split to split the files in whatever sizes you want.

split -bm

split -10m temp.tar.gz myfiles

This will create myfilesxa to myfilesx*.

You can regroup them using cat

cat myfilesxa myfilesxb myfilesxc >temp.tar.gz

HTH
Umapathy
Arise Awake and Stop NOT till the goal is Reached!

Re: Split files using tar

Of course, you could also just install rar on the server.
Karthik S S
Honored Contributor

Re: Split files using tar

Hi All,

Thanks .. I tried the following,

csplit -k hi.tar 70000 '{69999}'

(creates 4 files xx0*)

compare the size (doesn't match)

root@fep1:/depot/tartest>du -sk hi.tar xx0*
34660 hi.tar
6426 xx00
8526 xx01
9750 xx02
1374 xx03
root@fep1:/depot/tartest>bc
6426+8526+9750+1374
26076
quit

Am I missing something? Do I have to club these files using cat??


-Karthik S S
For a list of all the ways technology has failed to improve the quality of life, please press three. - Alice Kahn
Karthik S S
Honored Contributor

Re: Split files using tar

Thank you Umapathy .. it works ..!!

Thanks,
Karthik S S
For a list of all the ways technology has failed to improve the quality of life, please press three. - Alice Kahn