Unix questions - Untar to one file

This is Interesting: Free IT Magazines  
Home > Archive > Unix questions > December 2005 > Untar to one file





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Untar to one file
andre.cohen@gmail.com

2005-12-08, 5:57 pm

I have a series of tar (.Z) files which I would like to extract into
one file. All the files in the archives are ASCII so there should be no
problem combining all the files into on. What would be the easiest way
to do this?

Thanks in advance
~Andre

Aawara Chowdhury

2005-12-08, 5:57 pm

In <1134050586.436274.16580@g47g2000cwa.googlegroups.com>,
andre.cohen@gmail.com <andre.cohen@gmail.com> wrote:

> I have a series of tar (.Z) files which I would like to extract into
> one file. All the files in the archives are ASCII so there should be no
> problem combining all the files into on. What would be the easiest way
> to do this?


Something like ....

cat filename.tar | tar -Ox >> new-filename

AC
--
In America, through pressure of conformity, there is freedom of choice,
but nothing to choose from - Peter Ustinov.
Aawara Chowdhury

2005-12-08, 5:57 pm

In <dpggle.84k.aawara.NM0.2a@nohome.org>,
Aawara Chowdhury <aawara@nohome.org> wrote:

> In <1134050586.436274.16580@g47g2000cwa.googlegroups.com>,
> andre.cohen@gmail.com <andre.cohen@gmail.com> wrote:
>

Oops, just saw they are compressed files. So change:
[vbcol=seagreen]
> cat filename.tar | tar -Ox >> new-filename


to

cat filename.tar.Z | uncompress | tar -Ox >> new-filename

AC
--
In America, through pressure of conformity, there is freedom of choice,
but nothing to choose from - Peter Ustinov.
Chris F.A. Johnson

2005-12-08, 5:57 pm

On 2005-12-08, andre.cohen@gmail.com wrote:
> I have a series of tar (.Z) files which I would like to extract into
> one file. All the files in the archives are ASCII so there should be no
> problem combining all the files into on. What would be the easiest way
> to do this?


Do you have tar files (usually end with .tar), compressed files
(end with .Z), or compressed tar files (usually end with .tar.Z)?

To extract a tar archive to a single file, use the -O option if
your version of tar has it, or, if not, extract the files into a
temporary directory then cat them into a single file.

If they are compressed files, use 'uncompress -c' to uncompress
them to stdout and redirect that output to a file:

uncompress -c *.Z > NEWFILE

If they are compressed tar files, combine the two methods. Some tar
versions, such as GNU, can uncompress the files as well as
unarchive them. If you have (or another which will
uncompress/ungzip compressed files and sent the output to stdout):

for file in *.tar.Z
do
tar -Oxzf "$file"
done > NEWFILE

--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com