problem uncompressing tar.gz files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers problem uncompressing tar.gz files
# 8  
Old 02-05-2005
i like to use

gunzip < filename | tar xvf -
# 9  
Old 02-05-2005
Quote:
Originally Posted by girlie_admin
i like to use

gunzip < filename | tar xvf -
I use basically the same method, but there's no need for the redirection....

gunzip filename | tar xvf -

does the same thing. I like to save keystrokes!

And as thumsup9 hints, using GNU tar, you can save even more keystrokes by using the builtin gzip decompression

tar xvzf foo.tar.gz

Cheers
ZB
# 10  
Old 02-05-2005
I'm actually not even sure why i use redirect? i saw in an example years ago and have been using it ever since.
If I can save keystroke I certainly will.
i think i will adopt tar xvzf as my new, preferred method Smilie


Quote:
Originally Posted by zazzybob
I use basically the same method, but there's no need for the redirection....

gunzip filename | tar xvf -

does the same thing. I like to save keystrokes!

And as thumsup9 hints, using GNU tar, you can save even more keystrokes by using the builtin gzip decompression

tar xvzf foo.tar.gz

Cheers
ZB
# 11  
Old 02-05-2005
Quote:
Originally Posted by girlie_admin
I'm actually not even sure why i use redirect? i saw in an example years ago and have been using it ever since.
If I can save keystroke I certainly will.
i think i will adopt tar xvzf as my new, preferred method Smilie
That z flag on tar is not universal. As for using redirect, that's why I do and I'm not gonna switch. See this thread for part of the reason. The other part is that keystrokes are a cheap resource even for a slow typist like me. I often use superfluous parentheses in complex expressions. And in a script, I prefer
variable="string"
over
variable=string

In the same way, "gunzip < file | program" seems more clear than "gunzip file | program" especially if the reader never heard of gunzip. Of course, on the other hand, "gunzip < file" isn't going to fly. Here gunzip needs the old filename to construct the new filename. So rather than blindly adopting one technique or the other, be aware of the issues and make your own choice. There's not really a right or wrong here.
# 12  
Old 02-06-2005
I actually had the occasion to test these tonight.

tar didn't support the z switch
tar xvzf filename.tar.gz
tar: z: unknown option
Usage: tar {txruc}[vfbFXhiBEelmopwnq[0-7]] [-k size] [tapefile] [blocksize] [exclude-file] [-I include-file] files ...

gunzip without the redirection operator only unzip's the file, pipe to tar didn't seem to work
gunzip filename.tar.gz | tar xvf -
tar: blocksize = 0


Therefore, i stand with my original command line of:
gunzip < filename.tar.gz | tar xvf -

Since it is the only command line that did what I needed.
Smilie Smilie Smilie



Quote:
Originally Posted by Perderabo
That z flag on tar is not universal. As for using redirect, that's why I do and I'm not gonna switch. See this thread for part of the reason. The other part is that keystrokes are a cheap resource even for a slow typist like me. I often use superfluous parentheses in complex expressions. And in a script, I prefer
variable="string"
over
variable=string

In the same way, "gunzip < file | program" seems more clear than "gunzip file | program" especially if the reader never heard of gunzip. Of course, on the other hand, "gunzip < file" isn't going to fly. Here gunzip needs the old filename to construct the new filename. So rather than blindly adopting one technique or the other, be aware of the issues and make your own choice. There's not really a right or wrong here.
# 13  
Old 02-06-2005
The "z" switch to tar is supported in (primarily) GNU tar. You can get the gnu utilities from www.gnu.org and compile them for your system - in my opinion they are superior to a lot of the standard utilities supplied with most UNIX flavours, but of course this is just a personal preference.

Something else to throw into the melting pot is (under Linux)

zcat foo.tar.gz | tar xvf -

Some systems use "gzcat" instead.

Under certain circumstances (particularly within scripts) my rule of "saving keystrokes" doesn't apply. I'll always use ${varname} over $varname, string="value" over string=value, etc.... Whatever float's your boat I guess Smilie

Cheers
ZB
# 14  
Old 02-07-2005
Quote:
Originally Posted by zazzybob
zcat foo.tar.gz | tar xvf -

Some systems use "gzcat" instead.
zazzybob,

zcat is compatible with compress/uncompress and gzcat with gzip/gunzip.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. OS X (Apple)

Uncompressing but not extracting tar.Z file

Hi I have a few hundred files with extension .tar.Z. These files were archived (tar) and compressed (Z) on a UNIX system. I need to unzip them but not extract them. In other words they need to go to .tar extension. I would like to do this on my MAC or on a windows pc. I do not have a UNIX... (3 Replies)
Discussion started by: kalbano
3 Replies

2. Shell Programming and Scripting

Uncompressing .zip file specific directory Fedora 14

Hello, I have Fedora 14 installed on my machine I have a .zip file ( some latex package) which I want to unzip to some location in the Latex paths /usr/share.../texmf/.. so I went to super user mode, created the directory for this package over there, mkdir logo and tried... (1 Reply)
Discussion started by: ajayram
1 Replies

3. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

4. Shell Programming and Scripting

tar doubts - problem with tar

The below tar command works fine for me, tar -cvf - `find ./srcdir -type d` | (cd ./destdir ; tar -xvf - ) but this version is giving error to me: cd ./srcdir && tar -cf - . | gzip -9 | cd ../destdir && gzip -d | tar -xf - error is: gzip: compressed data not read from a terminal.... (2 Replies)
Discussion started by: royalibrahim
2 Replies

5. UNIX for Advanced & Expert Users

How to create a Tar of multiple Files in Unix and FTP the tar to Windows.

Hi, On my Unix Server in my directory, I have 70 files distributed in the following directories (which have several other files too). These files include C Source Files, Shell Script Source Files, Binary Files, Object Files. a) /usr/users/oracle/bin b) /usr/users/oracle... (1 Reply)
Discussion started by: marconi
1 Replies

6. Shell Programming and Scripting

extract one file form .tar.gz without uncompressing .tar.gz file

hi all, kindly help me how to extract one file form .tar.gz without uncompressing .tar.gz file. thanks in advance bali (2 Replies)
Discussion started by: balireddy_77
2 Replies

7. UNIX for Advanced & Expert Users

Untaring *.tar.tar files

Hi all, How to untar a file with .tar.tar extension. A utility that i downloaded from net had this extension. Thanks in advance, bubeshj. (6 Replies)
Discussion started by: bubeshj
6 Replies

8. AIX

uncompressing file

Hi, how do u uncompress a .Z file? i have a file called software.all.Z and have to change it to software.all. how to do that? thanks! karthik (3 Replies)
Discussion started by: karthikosu
3 Replies

9. Solaris

uncompressing a .gz file

Hi Friends, i am trying to uncompress a file which is of the following type filename.tar.gz. when i am using gunzip filename.tar.gz to unzip it, i am getting the error as filename .tar.gz: invalid compressed data--format violated what is the mistake that i am doing ? any other way to... (2 Replies)
Discussion started by: sveera
2 Replies

10. Programming

Uncompressing a Linux file on HP-UX

Hi!! All, I have a compressed C file made on Linux. On Linux I used to uncompress it using the command: zcat filename -xvf- |tar I am not able to uncompress the same on Hp-UX-10.2. Could someone help me out how to do it ?? Do I have to use any other command to uncompress it?? (2 Replies)
Discussion started by: jyotipg
2 Replies
Login or Register to Ask a Question