LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-09-2013, 01:42 AM   #1
ytyyutianyun
Member
 
Registered: Nov 2011
Posts: 63

Rep: Reputation: Disabled
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?
 
Old 12-09-2013, 01:54 AM   #2
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora
Posts: 1,692

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by ytyyutianyun View Post
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 | <....>
 
1 members found this post helpful.
Old 12-09-2013, 02:07 AM   #3
ytyyutianyun
Member
 
Registered: Nov 2011
Posts: 63

Original Poster
Rep: Reputation: Disabled
Smile

Quote:
Originally Posted by berndbausch View Post
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_ &
 
Old 12-09-2013, 09:03 AM   #4
ytyyutianyun
Member
 
Registered: Nov 2011
Posts: 63

Original Poster
Rep: Reputation: Disabled
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?

Last edited by ytyyutianyun; 12-09-2013 at 09:05 AM.
 
Old 12-09-2013, 09:12 AM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
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.
 
Old 12-09-2013, 10:20 PM   #6
ytyyutianyun
Member
 
Registered: Nov 2011
Posts: 63

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by colucix View Post
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?

Last edited by ytyyutianyun; 12-09-2013 at 10:21 PM.
 
Old 12-11-2013, 06:24 AM   #7
WarTurkey
Member
 
Registered: Jun 2009
Location: Ambler, PA, United States
Distribution: Debian, Arch
Posts: 67

Rep: Reputation: 16
What is the command that you used to concatenate the split files?
 
Old 12-11-2013, 06:26 AM   #8
WarTurkey
Member
 
Registered: Jun 2009
Location: Ambler, PA, United States
Distribution: Debian, Arch
Posts: 67

Rep: Reputation: 16
And did you have a backup of that "3d_mesh-0100.cas" file? Otherwise it looks like it was overwritten after your first command...
 
Old 12-11-2013, 11:44 PM   #9
ytyyutianyun
Member
 
Registered: Nov 2011
Posts: 63

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by WarTurkey View Post
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
 
Old 12-12-2013, 03:18 AM   #10
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
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.
 
Old 12-12-2013, 08:08 PM   #11
ytyyutianyun
Member
 
Registered: Nov 2011
Posts: 63

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by colucix View Post
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_

Last edited by ytyyutianyun; 12-12-2013 at 08:14 PM.
 
  


Reply

Tags
cat, split, tar, tgz


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Change of suffix format on "split" tar archive files scramble64 Linux - Software 2 11-24-2011 06:41 AM
Editing a compressed tar.. iuselinux Linux - General 5 03-14-2011 12:28 PM
Tar split into small files jmoschetti45 Linux - Software 1 02-07-2011 06:44 PM
tar, split, burn to dvd result to tar file corruption fedusr Fedora 8 11-30-2007 05:39 PM
How to uninstall program compressed with tar.gz ronronson Linux - Newbie 1 06-11-2004 04:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration