How to untar .tar.gz when you don't have "-z" option? - Unix

This is a discussion on How to untar .tar.gz when you don't have "-z" option? - Unix ; I have TAR files compressed with gzip option "-z" that I must uncompress on a different remote system that does not have the gzip option with "tar -xvf". How do I uncompress without "-z"? I am not given the luxury ...

+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 20 of 47

Thread: How to untar .tar.gz when you don't have "-z" option?

  1. How to untar .tar.gz when you don't have "-z" option?

    I have TAR files compressed with gzip option "-z" that I must
    uncompress on a different remote system that does not have the gzip
    option with "tar -xvf". How do I uncompress without "-z"? I am not
    given the luxury of reconfiguring the remote system to do anything
    about this (it's a FreeBSD Unix platform).

    Thanx
    Phil


  2. Re: How to untar .tar.gz when you don't have "-z" option?

    phillip.s.powell@gmail.com wrote:
    ) I have TAR files compressed with gzip option "-z" that I must
    ) uncompress on a different remote system that does not have the gzip
    ) option with "tar -xvf". How do I uncompress without "-z"? I am not
    ) given the luxury of reconfiguring the remote system to do anything
    ) about this (it's a FreeBSD Unix platform).

    gunzip -c | tar -xvf -

    If you don't have gunzip (or gzip -d) installed, you're basically screwed.

    HTH, HAND.


    SaSW, Willem
    --
    Disclaimer: I am in no way responsible for any of the statements
    made in the above text. For all I know I might be
    drugged or something..
    No I'm not paranoid. You all think I'm paranoid, don't you !
    #EOT

  3. Re: How to untar .tar.gz when you don't have "-z" option?

    On 24 Oct 2005 13:25:59 -0700, phillip.s.powell@gmail.com wrote:
    > I have TAR files compressed with gzip option "-z" that I must
    > uncompress on a different remote system that does not have the gzip
    > option with "tar -xvf". How do I uncompress without "-z"? I am not
    > given the luxury of reconfiguring the remote system to do anything
    > about this (it's a FreeBSD Unix platform).


    A FreeBSD system without gzip? Are you sure it's not there? Could it
    just not be in your path?

    But, if it's really not there, then your only choice is to unzip it on a
    system that does have gzip.

    Dave Hinz


  4. Re: How to untar .tar.gz when you don't have "-z" option?

    Willem wrote:
    > phillip.s.powell@gmail.com wrote:
    >
    > ) I have TAR files compressed with gzip option "-z" that I must
    > ) uncompress on a different remote system that does not have the gzip
    > ) option with "tar -xvf". How do I uncompress without "-z"? I am not
    > ) given the luxury of reconfiguring the remote system to do anything
    > ) about this (it's a FreeBSD Unix platform).
    >
    > gunzip -c | tar -xvf -
    >
    > If you don't have gunzip (or gzip -d) installed, you're basically screwed.


    Nah, the file had to be transferred from the source host
    to the target host somehow. If the target host lacks
    gunzip, the source host had a -z option in tar and will
    therefore had gzip and/or gunzip available.

    ftp/scp/whatever file.tar.gz
    zcat file.tar.gz | tar -xvf -

    or

    gzip -u file.tar.gz
    ftp/scp/whatever file.tar
    tar -xvf file.tar


  5. Re: How to untar .tar.gz when you don't have "-z" option?

    phillip.s.powell@gmail.com writes:
    > I have TAR files compressed with gzip option "-z" that I must
    > uncompress on a different remote system that does not have the gzip
    > option with "tar -xvf". How do I uncompress without "-z"? I am not
    > given the luxury of reconfiguring the remote system to do anything
    > about this (it's a FreeBSD Unix platform).


    It almost sounds like you're talking about a "-z" option to the gzip
    program, but I'm sure you're referring to tar's "-z" option that
    causes it to invoke gzip.

    As long as you have tar and gzip commands, it's easy enough to invoke
    them yourself, eg., "gzip -d < foo.tar.gz | tar xvf -".

    Or you can install GNU tar. The latest version recognizes gzipped
    tarballs automatically, so you don't even need to use the 'z' option
    explicitly. This doesn't require reconfiguring the remote system; you
    can just build and install it somwehere under your home directory.

    --
    Keith Thompson (The_Other_Keith) kst-u@mib.org
    San Diego Supercomputer Center <*>
    We must do something. This is something. Therefore, we must do this.

  6. Re: How to untar .tar.gz when you don't have "-z" option?

    Begin
    On 2005-10-24, Keith Thompson wrote:
    > phillip.s.powell@gmail.com writes:
    >> (it's a FreeBSD Unix platform).

    ^^^^^^^

    > As long as you have tar and gzip commands, it's easy enough to invoke
    > them yourself, eg., "gzip -d < foo.tar.gz | tar xvf -".


    FreeBSD comes with both g(un)zip and tar in the base system.


    > Or you can install GNU tar.


    FreeBSD has gnu tar available in the base system as tar (4.*) or gtar
    (5.*). The bsdtar that is `tar' on FreeBSD 5.* ignores -z on extraction
    or test because it automatically recognizes compression anyway.


    The only reason I can think of right now why OP would not be able to use
    tar is because he's in a jail(8) and tar didn't get installed. In which
    case it is probably a good idea to talk to the admin and ask for tar to
    be copied as well.


    --
    j p d (at) d s b (dot) t u d e l f t (dot) n l .

  7. Re: How to untar .tar.gz when you don't have "-z" option?

    In comp.compression Willem wrote:
    > phillip.s.powell@gmail.com wrote:
    > ) I have TAR files compressed with gzip option "-z" that I must
    > ) uncompress on a different remote system that does not have the gzip
    > ) option with "tar -xvf". How do I uncompress without "-z"? I am not
    > ) given the luxury of reconfiguring the remote system to do anything
    > ) about this
    >
    > gunzip -c | tar -xvf -
    >
    > If you don't have gunzip (or gzip -d) installed, you're basically screwed.


    Well, not necessary.

    gunzip < file.tar.gz | ssh remote.system "cd $target_dir && tar x"

    > (it's a FreeBSD Unix platform).


    Sounds extremely unlikely that you are really missing required tools.

    M.

  8. Re: How to untar .tar.gz when you don't have "-z" option?

    Sorry, not an option in this case. It has to be packaged up and sent
    to a system that doesn't have "tar -z" option (although it does have
    gzip/gunzip though)

    Phil


  9. Re: How to untar .tar.gz when you don't have "-z" option?

    I can't do that, this is a remote hosting platform and the admin will
    not install anything on the base system for any of his clients.

    Phil


  10. Re: How to untar .tar.gz when you don't have "-z" option?

    Basically I have to set it up so that the source and destination may,
    or may not, have "g[un]zip" capabilities since this is a portable web
    application and thus, the packager has to be equally portable (note
    that it's a UNIX-only packager for now, will have to create a Windows
    version whenever I feel like it).

    An engineering co-worker helped stumble me onto this option:

    blah=`which gunzip | grep -E 'no gunzip'`
    # LOOK FOR STRING CONTENT IN $blah - IF IT HAS CONTENT, NO GUNZIP,
    ELSE, GUNZIP

    Phil


  11. Re: How to untar .tar.gz when you don't have "-z" option?

    On 26 Oct 2005 07:08:16 -0700, phillip.s.powell@gmail.com wrote:
    > Sorry, not an option in this case. It has to be packaged up and sent
    > to a system that doesn't have "tar -z" option (although it does have
    > gzip/gunzip though)


    Nobody knows what or who you are answering, because you're using
    google's brain-dead interface which doesn't default to including
    context. Please change that default, if you'd like your messages to
    make sense.


  12. Re: How to untar .tar.gz when you don't have "-z" option?

    On 26 Oct 2005 07:09:37 -0700, phillip.s.powell@gmail.com wrote:
    > I can't do that, this is a remote hosting platform and the admin will
    > not install anything on the base system for any of his clients.


    Sounds like you need a better hosting company. allmanaged.com doesn't
    suck.


  13. Re: How to untar .tar.gz when you don't have "-z" option?

    I am not used to this interface, sorry! AUGH!

    Ok, an update.. I was able to to find an alternative to "tar -z", only
    that it fails using FreeBSD UNIX:

    [BASH]
    cd $1
    hasGunzip=`which gunzip | grep -E 'no gunzip'`
    if [ -n $hasGunzip ]; then
    gunzip -c $1/$3_$4.tar.gz | tar -xvf
    else
    echo "You can't unzip, you're screwed"
    exit
    fi
    [/BASH]

    However, upon using this code I get the following error message:


    tar: usage tar [-]{txruc}[eONvVwAfblhm{op}][0-7[lmh]] [tapefile]
    [blocksize] [[-C directory] file] ...
    However, using Red Hat Enterprise Level 3 version of UNIX, the
    untarring takes place with no faults of any kind.

    The destination, however, is FreeBSD so it must work for both platforms
    of UNIX.

    Phil

    phillip.s.powell@gmail.com wrote:
    > Sorry, not an option in this case. It has to be packaged up and sent
    > to a system that doesn't have "tar -z" option (although it does have
    > gzip/gunzip though)
    >
    > Phil



  14. Re: How to untar .tar.gz when you don't have "-z" option?

    On 26 Oct 2005 07:12:21 -0700, phillip.s.powell@gmail.com wrote:

    >Basically I have to set it up so that the source and destination may,
    >or may not, have "g[un]zip" capabilities since this is a portable web
    >application and thus, the packager has to be equally portable (note
    >that it's a UNIX-only packager for now, will have to create a Windows
    >version whenever I feel like it).
    >
    >An engineering co-worker helped stumble me onto this option:
    >
    >blah=`which gunzip | grep -E 'no gunzip'`
    ># LOOK FOR STRING CONTENT IN $blah - IF IT HAS CONTENT, NO GUNZIP,
    >ELSE, GUNZIP


    Note that the behavior of which(1) is dependent on what system and what
    shell you're running. I think it'd be more reliable to test the return
    value of which rather than grepping its output.

    As someone already pointed out, if you can externally decompress the archive
    and pipe it to tar, you don't need a tar -z option.

    If you have gzip, you also have gunzip capability via gzip -d.

    Or you could just skip the compression and distribute a .tar file.

    -Scott

  15. Re: How to untar .tar.gz when you don't have "-z" option?

    On 26 Oct 2005 08:31:51 -0700, phillip.s.powell@gmail.com wrote:
    > I am not used to this interface, sorry! AUGH!


    If you subscribe to news.individual.net for 10 euro a year (13 bucks or
    so), you can use a real newsreader and not have to suffer with google.

    > hasGunzip=`which gunzip | grep -E 'no gunzip'`


    All that proves is that it's not in your path. Ask your draconian
    hosting company where gzip and whatever you need, is located. If they
    don't know, or won't tell you, or it's not there and they won't fix
    that, get a better hosting company.


  16. Re: How to untar .tar.gz when you don't have "-z" option?

    In article <1130340711.877575.274190@g14g2000cwa.googlegroups. com>,
    wrote:
    >
    >
    >I am not used to this interface, sorry! AUGH!
    >
    >Ok, an update.. I was able to to find an alternative to "tar -z", only
    >that it fails using FreeBSD UNIX:
    >
    >[BASH]
    >cd $1
    >hasGunzip=`which gunzip | grep -E 'no gunzip'`
    >if [ -n $hasGunzip ]; then
    > gunzip -c $1/$3_$4.tar.gz | tar -xvf
    >else
    > echo "You can't unzip, you're screwed"
    > exit
    >fi
    >[/BASH]
    >
    >However, upon using this code I get the following error message:
    >
    >
    >
    >tar: usage tar [-]{txruc}[eONvVwAfblhm{op}][0-7[lmh]] [tapefile]
    >[blocksize] [[-C directory] file] ...
    >
    >
    >
    >However, using Red Hat Enterprise Level 3 version of UNIX, the
    >untarring takes place with no faults of any kind.
    >
    >The destination, however, is FreeBSD so it must work for both platforms
    >of UNIX.
    >
    >Phil
    >
    >phillip.s.powell@gmail.com wrote:
    >> Sorry, not an option in this case. It has to be packaged up and sent
    >> to a system that doesn't have "tar -z" option (although it does have
    >> gzip/gunzip though)
    >>
    >> Phil

    >


    Just a note:

    If the FreeBSD system you are using doesn't support -z, then it is something
    the hosting company has done to break it. Out of the box, both FreeBSD 4.x &
    FreeBSD 5.x support 'z' in the default /usr/bin/tar


    Ted

  17. Re: How to untar .tar.gz when you don't have "-z" option?

    See below.. thanx

    Dave Hinz wrote:
    > On 26 Oct 2005 08:31:51 -0700, phillip.s.powell@gmail.com wrote:
    > > I am not used to this interface, sorry! AUGH!

    >
    > If you subscribe to news.individual.net for 10 euro a year (13 bucks or
    > so), you can use a real newsreader and not have to suffer with google.
    >
    > > hasGunzip=`which gunzip | grep -E 'no gunzip'`

    >
    > All that proves is that it's not in your path. Ask your draconian
    > hosting company where gzip and whatever you need, is located. If they
    > don't know, or won't tell you, or it's not there and they won't fix
    > that, get a better hosting company.


    Thanx, but that is not quite my problem. The problem is that I get an
    error message when I'm trying to pipe a gunzip command on the file into
    a tar command.

    [BASH]
    gunzip -c $1/$3_$4.tar.gz | tar -xvf
    [/BASH]

    produces

    tar: usage tar [-]{txruc}[eONvVwAfblhm{op}][0-7[lmh]] [tapefile]
    [blocksize] [[-C directory] file] ...
    Phil


  18. Re: How to untar .tar.gz when you don't have "-z" option?

    On my Linux system, I can compress the archive and pipe it to tar; on
    the FreeBSD UNIX system I cannot decompress the archive and pipe to tar

    [BASH]
    gunzip -c $1/$3_$4.tar.gz | tar -xvf
    [/BASH]

    produces

    tar: usage tar [-]{txruc}[eONvVwAfblhm{op}][0-7[lmh]] [tapefile]
    [blocksize] [[-C directory] file] ...
    Phil

    Scott wrote:
    > On 26 Oct 2005 07:12:21 -0700, phillip.s.powell@gmail.com wrote:
    >
    > >Basically I have to set it up so that the source and destination may,
    > >or may not, have "g[un]zip" capabilities since this is a portable web
    > >application and thus, the packager has to be equally portable (note
    > >that it's a UNIX-only packager for now, will have to create a Windows
    > >version whenever I feel like it).
    > >
    > >An engineering co-worker helped stumble me onto this option:
    > >
    > >blah=`which gunzip | grep -E 'no gunzip'`
    > ># LOOK FOR STRING CONTENT IN $blah - IF IT HAS CONTENT, NO GUNZIP,
    > >ELSE, GUNZIP

    >
    > Note that the behavior of which(1) is dependent on what system and what
    > shell you're running. I think it'd be more reliable to test the return
    > value of which rather than grepping its output.
    >
    > As someone already pointed out, if you can externally decompress the archive
    > and pipe it to tar, you don't need a tar -z option.
    >
    > If you have gzip, you also have gunzip capability via gzip -d.
    >
    > Or you could just skip the compression and distribute a .tar file.
    >
    > -Scott



  19. Re: How to untar .tar.gz when you don't have "-z" option?

    2005-10-26, 08:31(-07), phillip.s.powell@gmail.com:
    > I am not used to this interface, sorry! AUGH!
    >
    > Ok, an update.. I was able to to find an alternative to "tar -z", only
    > that it fails using FreeBSD UNIX:
    >
    > [BASH]
    > cd $1
    > hasGunzip=`which gunzip | grep -E 'no gunzip'`
    > if [ -n $hasGunzip ]; then
    > gunzip -c $1/$3_$4.tar.gz | tar -xvf
    > else
    > echo "You can't unzip, you're screwed"
    > exit
    > fi
    > [/BASH]

    [...]

    There are several issues in your code.

    cd -P -- "$1" || exit
    if
    type gunzip > /dev/null 2>&1 || {
    type gzip > /dev/null 2>&1 &&
    gunzip() { gzip -d "$@"; }
    }
    then
    gunzip -c < "$1/${3}_$4.tar.gz" | tar xvf -
    else
    echo >&2 "You can't gunzip, you're screwed"
    fi

    To sum up.

    - leaving a variable unquoted has a very special meaning in
    shells, you should (almost) never do that.
    - cd without options defaults to cd -L (in POSIX shells). That
    may not be what you want.
    - if cd fails, you should not go on with the rest of the script.
    - When passing "variable" arguments to commands, you should
    ensure that the command doesn't take the argument for an
    option by clearly marking the end of options with "--".
    - which is a non-portable, non reliable command. type is the
    Bourne equivalent of that (initially csh) command (and command
    -v is the POSIX one)
    - grep -E, though POSIX is not very portable
    - the f option to find takes one argument which is the file name
    - tar options historically don't start with "-"

    --
    Stéphane

  20. Re: How to untar .tar.gz when you don't have "-z" option?

    Hi,

    >
    > tar: usage tar [-]{txruc}[eONvVwAfblhm{op}][0-7[lmh]] [tapefile]
    > [blocksize] [[-C directory] file] ...
    >


    $ man tar

    So long,
    Thomas

+ Reply to Thread
Page 1 of 3 1 2 3 LastLast