Link to home
Start Free TrialLog in
Avatar of Gnustome
Gnustome

asked on

Unzipping and detarring a file, again

I am trying to unzip and detar a file, fileback.tgz, by typing gzip -dc fileback.tgz | tar -xvf.  The system (Debian 2.4.18) returns a reply: tar: option requires an argument -- f.  I have also tried to unzip the file first, with the intention of detarring the result.  When I do this, text flies by on the monitor for about 15 seconds, but the file name is unchanged.  I don't know what I'm doing wrong or what to do.  Your help will be appreciated.
Avatar of yuzh
yuzh

Assume that you are using GNU tar, you can do:

cd /dir-to-restore
tar -zxf fileback.tgz

I suggest you to use the following command to verify what's in the tarball first:

tar -ztvf fileback.tgz


In case you don't have GNU tar installed on your system, you can do:

gunzip fileback.tgz

then you get: fileback.tar

the use:
to verify what's in the tar ball
                  tar tvf fileback.tar
to untart the files
                  tar xvf fileback.tar

cheers!
Or, using the form in the question you can do 'gzip -d <file.tgz | tar xvf -'
ASKER CERTIFIED SOLUTION
Avatar of linxit
linxit

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No, you DON'T NEED gnu tar! Use either
  gzip -dc filename | tar xvf -
or
  gzcat filename | tar xvf -
The "-" is important for tar as the filename must be provided. The - stands for stdin
Normally on Linux you have two commands

lz <zipped-tarred-file>

to show the contents of a package and

uz <zipped-tarred-file>

to unzip the package in the current directory.

I find these much easier than remembering all the options that are necessary for gzip and tar.

Dominik.
This is a general question. You can do either
a) use specific "short cuts" like lz or uz and be happy and don't care
    about these many options and UNIX command around,
or
b) use the "generic" UNIX commands like "tar" and "gzcat" and be
    an experienced UNIX admin who will be able to work on many
    different UNIX brands.
It's just a question of personal taste ...