LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Using split and tar to get the compressed files (https://www.linuxquestions.org/questions/linux-newbie-8/using-split-and-tar-to-get-the-compressed-files-4175487346/)

ytyyutianyun 12-09-2013 12:42 AM

Using split and tar to get the compressed files
 
My code is:
Code:

nohup tar -zcvf *.cas | split -d -b 200m &
My document is

Quote:

3d_mesh-0100.cas
3d_mesh-0200.cas
3d_mesh-0300.cas
3d_mesh-0400.cas
3d_mesh-0500.cas
3d_mesh-0600.cas
3d_mesh-0700.cas
3d_mesh-0800.cas
3d_mesh-0900.cas
3d_mesh-1000.cas
3d_mesh-1100.cas
Each is 118mb

But strange thing is the size of 3d_mesh-0100.cas became bigger, and nothing else happens.

What I want is to put into all the *.cas into file and then spilt into documents. Then how can I do it?

berndbausch 12-09-2013 12:54 AM

Quote:

Originally Posted by ytyyutianyun (Post 5077717)
My code is:
Code:

nohup tar -zcvf *.cas | split -d -b 200m &

Your tar command uses the first cas file as the archive name. If you want to create the archive on Standard Output, you have to write:

Code:

nohup tar -zcvf - *.cas | <....>

ytyyutianyun 12-09-2013 01:07 AM

Quote:

Originally Posted by berndbausch (Post 5077724)
Your tar command uses the first cas file as the archive name. If you want to create the archive on Standard Output, you have to write:

Code:

nohup tar -zcvf - *.cas | <....>

You are great
And I use the code well

Code:

nohup tar -zcvf - *.cas | split -d -b 200m - film_ &

ytyyutianyun 12-09-2013 08:03 AM

split and cat and unzip error?
 
I use the code to package files and split

Code:

nohup tar -zcvf - *.cas | split -d -b 200m - film_ &
My document is

Quote:

3d_mesh-0100.cas
3d_mesh-0200.cas
3d_mesh-0300.cas
3d_mesh-0400.cas
3d_mesh-0500.cas
3d_mesh-0600.cas
3d_mesh-0700.cas
3d_mesh-0800.cas
3d_mesh-0900.cas
3d_mesh-1000.cas
3d_mesh-1100.cas
and then in order to test whether it is good. I merged it and extract it
code : merge
Code:

cat film_* > cas_bak.tar.gz
and then
code: extract it
Code:

tar -zxvf cas_bak.tar.gz
But it shows that:
Quote:

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error exit delayed from previous errors
#
Why?

colucix 12-09-2013 08:12 AM

If you try
Code:

tar -zcvf - *.cas
you get
Code:

3d_mesh-0100.cas
3d_mesh-0200.cas
3d_mesh-0300.cas
3d_mesh-0400.cas
3d_mesh-0500.cas
3d_mesh-0600.cas
3d_mesh-0700.cas
3d_mesh-0800.cas
3d_mesh-0900.cas
3d_mesh-1000.cas
3d_mesh-1100.cas
gzip: compressed data not written to a terminal. Use -f to force compression.
For help, type: gzip -h
tar: Child returned status 1
tar: Error is not recoverable: exiting now

Therefore you can try the following using option -f of gzip:
Code:

tar -cvf - *.cas | gzip -cf | split -d -b 1m - film_
This should do the trick.

ytyyutianyun 12-09-2013 09:20 PM

Quote:

Originally Posted by colucix (Post 5077852)
If you try
Code:

tar -zcvf - *.cas
you get
Code:

3d_mesh-0100.cas
3d_mesh-0200.cas
3d_mesh-0300.cas
3d_mesh-0400.cas
3d_mesh-0500.cas
3d_mesh-0600.cas
3d_mesh-0700.cas
3d_mesh-0800.cas
3d_mesh-0900.cas
3d_mesh-1000.cas
3d_mesh-1100.cas
gzip: compressed data not written to a terminal. Use -f to force compression.
For help, type: gzip -h
tar: Child returned status 1
tar: Error is not recoverable: exiting now

Therefore you can try the following using option -f of gzip:
Code:

tar -cvf - *.cas | gzip -cf | split -d -b 1m - film_
This should do the trick.

I use the code:
Code:

tar -cvf - *.cas | gzip -cf | split -d -b 200m - film_
And when I merged and unrar it.

it shows:

Quote:

tar -zxvf cas_bak.tar.gz
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Archive contains obsolescent base-64 headers
tar: A lone zero block at 22581

tar: Error exit delayed from previous errors
Why?

WarTurkey 12-11-2013 05:24 AM

What is the command that you used to concatenate the split files?

WarTurkey 12-11-2013 05:26 AM

And did you have a backup of that "3d_mesh-0100.cas" file? Otherwise it looks like it was overwritten after your first command...

ytyyutianyun 12-11-2013 10:44 PM

Quote:

Originally Posted by WarTurkey (Post 5078888)
And did you have a backup of that "3d_mesh-0100.cas" file? Otherwise it looks like it was overwritten after your first command...

Because the strange "3d_mesh-0100.cas", so I delete it before running the command.

And I use this code to "merge"
Code:

cat film_* > cas_bak.tar.gz

colucix 12-12-2013 02:18 AM

It's difficult to debug this issue without having the same files. I tried what suggested on my system and it worked flawlessly. Anyway, first please tell us what is your operating system and which version of tar you have. Then, please try one step at a time, instead of the pipeline and check the results at each step. That is:
Code:

tar -cvf tmp.tar *.cas
gzip tmp.tar
split -d -b 1m tmp.tar.gz film_
cat film_* > cas_bak.tar.gz

check the files produced at each step and try to discover where the problem comes from.

ytyyutianyun 12-12-2013 07:08 PM

Quote:

Originally Posted by colucix (Post 5079334)
It's difficult to debug this issue without having the same files. I tried what suggested on my system and it worked flawlessly. Anyway, first please tell us what is your operating system and which version of tar you have. Then, please try one step at a time, instead of the pipeline and check the results at each step. That is:
Code:

tar -cvf tmp.tar *.cas
gzip tmp.tar
split -d -b 1m tmp.tar.gz film_
cat film_* > cas_bak.tar.gz

check the files produced at each step and try to discover where the problem comes from.

OS: Suse enterprise server
tar:tar (GNU tar) 1.15.1

And it is Ok,based the command saved in shell

Code:

mkdir splitfile
tar -zcvf splitfile/cas.tgz *.cas
split -d -b 200m splitfile/cas.tgz splitfile/cas_
tar -zcvf splitfile/dat.tgz *.dat
split -d -b 200m splitfile/dat.tgz splitfile/dat_



All times are GMT -5. The time now is 12:54 PM.