Professional Web Applications Themes

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

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...

  1. #1

    Default 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

    phillip.s.powell@gmail.com Guest

  2. #2

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

    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 <file.tar.gz> | tar -xvf -

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

    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
    Willem Guest

  3. #3

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

    On 24 Oct 2005 13:25:59 -0700, com <com> wrote: 

    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

    Dave Guest

  4. #4

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

    Willem wrote: 

    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

    Doug Guest

  5. #5

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

    com writes: 

    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) org <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Guest

  6. #6

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

    Begin <mib.org>
    On 2005-10-24, Keith Thompson <org> wrote: [/ref]
    ^^^^^^^
     

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

     

    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 .
    jpd Guest

  7. #7

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

    In comp.compression Willem <nl> wrote: 

    Well, not necessary.

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

    Sounds extremely unlikely that you are really missing required tools.

    M.
    Michal Guest

  8. #8

    Default 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

    phillip.s.powell@gmail.com Guest

  9. #9

    Default 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

    phillip.s.powell@gmail.com Guest

  10. #10

    Default 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

    phillip.s.powell@gmail.com Guest

  11. #11

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

    On 26 Oct 2005 07:08:16 -0700, com <com> wrote: 

    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.

    Dave Guest

  12. Moderated Post

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

    Removed by Administrator
    Dave Guest
    Moderated Post

  13. #13

    Default 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 ed"
    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

    com wrote: 

    phillip.s.powell@gmail.com Guest

  14. #14

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

    On 26 Oct 2005 07:12:21 -0700, com wrote:
     

    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
    Scott Guest

  15. #15

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

    On 26 Oct 2005 08:31:51 -0700, com <com> wrote: 

    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.
     

    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.

    Dave Guest

  16. #16

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

    In article <googlegroups.com>,
    <com> wrote: 
    >[/ref]

    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
    ted@loft.tnolan.com Guest

  17. #17

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

    See below.. thanx

    Dave Hinz wrote: 
    >
    > 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.

    >
    > 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.[/ref]

    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

    phillip.s.powell@gmail.com Guest

  18. #18

    Default 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: 
    >
    > 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[/ref]

    phillip.s.powell@gmail.com Guest

  19. #19

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

    2005-10-26, 08:31(-07), com: 
    [...]

    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 ed"
    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
    Stephane Guest

  20. #20

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

    Hi,
     

    $ man tar

    So long,
    Thomas
    Thomas Guest

Page 1 of 3 123 LastLast

Similar Threads

  1. No "Delete Pages" Option in Bookmarks' Right-Click Context Menu
    By Jack Danniel in forum Adobe Acrobat Windows
    Replies: 1
    Last Post: April 13th, 11:02 PM
  2. Replies: 0
    Last Post: October 17th, 07:29 AM
  3. #25744 [Com]: --with-sybase option is failing with "php_sybase_db.c:147:`tsrm_ls' undeclared"
    By yunlan at mail dot eestart dot com in forum PHP Development
    Replies: 1
    Last Post: October 17th, 07:20 AM
  4. Replies: 1
    Last Post: October 3rd, 06:06 PM
  5. #25744 [Csd->Opn]: --with-sybase option is failing with "php_sybase_db.c:147:`tsrm_ls' undeclared"
    By christian_m_caron at hotmail dot com in forum PHP Development
    Replies: 0
    Last Post: October 3rd, 06:01 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139