Compress (gzip) and move big file at the same time to different directoryon UNIX - Unix

This is a discussion on Compress (gzip) and move big file at the same time to different directoryon UNIX - Unix ; I have a big file 20Gb in size. The file system on which this file is located is not having enough space left to compress it. I want to compress the file but the compressed version should go in another ...

+ Reply to Thread
Results 1 to 13 of 13

Thread: Compress (gzip) and move big file at the same time to different directoryon UNIX

  1. Compress (gzip) and move big file at the same time to different directoryon UNIX

    I have a big file 20Gb in size. The file system on which this file is
    located is not having enough space left to compress it. I want to
    compress the file but the compressed version should go in another file
    system(directory) i.e. the gzip or compress utility should move it to
    another directory while compressing it. Can any one please help with
    this?

    Thanks


  2. Re: Compress (gzip) and move big file at the same time to different directoryon UNIX

    On 2006-03-03, nhk wrote:
    > I have a big file 20Gb in size. The file system on which this file is
    > located is not having enough space left to compress it. I want to
    > compress the file but the compressed version should go in another file
    > system(directory) i.e. the gzip or compress utility should move it to
    > another directory while compressing it. Can any one please help with
    > this?


    man gzip:

    -c --stdout --to-stdout
    Write output on standard output; keep original files unchanged.


    gzip -c BIGFILE > /path/to/new/file.gz


    --
    Chris F.A. Johnson, author |
    Shell Scripting Recipes: | My code in this post, if any,
    A Problem-Solution Approach | is released under the
    2005, Apress | GNU General Public Licence

  3. Re: Compress (gzip) and move big file at the same time to different directoryon UNIX

    2006-03-3, 15:36(-08), nhk:
    > I have a big file 20Gb in size. The file system on which this file is
    > located is not having enough space left to compress it. I want to
    > compress the file but the compressed version should go in another file
    > system(directory) i.e. the gzip or compress utility should move it to
    > another directory while compressing it. Can any one please help with


    gzip < /here/file > /there/file.gz

    --
    Stéphane

  4. Re: Compress (gzip) and move big file at the same time to different directoryon UNIX

    Thanks Stephane and Chris.

    Is there a way I can retain the date of the original file in the
    compressed file.
    Like when I gunzip the zipped file it can give the date of the original
    file.

    Thanks.


  5. Re: Compress (gzip) and move big file at the same time to different directoryon UNIX

    On 2006-03-06, nhk wrote:
    > Thanks Stephane and Chris.
    >
    > Is there a way I can retain the date of the original file in the
    > compressed file.
    > Like when I gunzip the zipped file it can give the date of the original
    > file.
    >
    > Thanks.


    This is done by default. The compress(1) command also tries to do it
    with the atime (I assume by "the date" you mean the mtime)

  6. Re: Compress (gzip) and move big file at the same time to different directoryon UNIX

    On 2006-03-06, Jordan Abel wrote:
    > On 2006-03-06, nhk wrote:
    >> Thanks Stephane and Chris.
    >>
    >> Is there a way I can retain the date of the original file in the
    >> compressed file.
    >> Like when I gunzip the zipped file it can give the date of the original
    >> file.
    >>
    >> Thanks.

    >
    > This is done by default. The compress(1) command also tries to do it
    > with the atime (I assume by "the date" you mean the mtime)


    Sorry, I didn't read for context - this _won't_ be done for the
    redirection trick named above.

    You could use tar.

    tar czf /elsewhere/file.tgz /original/file

  7. Re: Compress (gzip) and move big file at the same time to different directoryon UNIX

    "nhk" writes:
    > Is there a way I can retain the date of the original file in the
    > compressed file.
    > Like when I gunzip the zipped file it can give the date of the original
    > file.


    Of course: use GNU tar!

    tar zcf ${file}.tgz ${file}


    --
    __Pascal Bourguignon__ http://www.informatimago.com/

    What is this talk of 'release'? Klingons do not make software 'releases'.
    Our software 'escapes' leaving a bloody trail of designers and quality
    assurance people in it's wake.

  8. Re: Compress (gzip) and move big file at the same time to different directoryon UNIX

    Begin <878xrnw1jm.fsf@thalassa.informatimago.com>
    On 2006-03-07, Pascal Bourguignon wrote:
    > "nhk" writes:
    >> Is there a way I can retain the date of the original file in the
    >> compressed file. Like when I gunzip the zipped file it can give the
    >> date of the original file.

    >
    > Of course: use GNU tar!


    Why do you specifically mention gnu's not-so-compatible tar? Isn't this
    a normal feature of most if not all tars? I'd prefer star if the local
    tar isn't sufficient. The gnu tar implementation might be widely used,
    it is not universally used and neither is it universally compatible.


    To the OP: gzip only compresses data, it's not an archiver. If you also
    want to keep metadata and/or you want to pack multiple files together,
    you need an archiver, like tar, but tar doesn't compress. You can use
    both (tar, then gzip) if you want to. Or, some tars can automatically
    call gzip for you.


    --
    j p d (at) d s b (dot) t u d e l f t (dot) n l .
    This message was originally posted on Usenet in plain text.
    Any other representation, additions, or changes do not have my
    consent and may be a violation of international copyright law.

  9. Re: Compress (gzip) and move big file at the same time to different directoryon UNIX

    jpd writes:

    > Begin <878xrnw1jm.fsf@thalassa.informatimago.com>
    > On 2006-03-07, Pascal Bourguignon wrote:
    >> "nhk" writes:
    >>> Is there a way I can retain the date of the original file in the
    >>> compressed file. Like when I gunzip the zipped file it can give the
    >>> date of the original file.

    >>
    >> Of course: use GNU tar!

    >
    > Why do you specifically mention gnu's not-so-compatible tar? Isn't this
    > a normal feature of most if not all tars? I'd prefer star if the local
    > tar isn't sufficient. The gnu tar implementation might be widely used,
    > it is not universally used and neither is it universally compatible.


    Because I've specifically used GNU tar exclusively for fifteen years
    on all the unix system I used, exactly for this reason.

    Some tar don't have -z or -j.
    Some tar don't even have -f -, so you can write: gzip -d < $file | tar -xf -

    So either you have a lot of hard disk space and bear the inconvenience of typing:

    gzip -d $archive
    tar xf $archive

    or

    tar cf ${file}.tar $file
    gzip ${file}.tar



    or you download GNU tar once for all and type:

    tar zxf $archive

    or

    tar zcf ${file}.tar.gz $file


    --
    __Pascal Bourguignon__ http://www.informatimago.com/

    THIS IS A 100% MATTER PRODUCT: In the unlikely event that this
    merchandise should contact antimatter in any form, a catastrophic
    explosion will result.

  10. Re: Compress (gzip) and move big file at the same time to different directoryon UNIX

    On 2006-03-07, Pascal Bourguignon wrote:
    > jpd writes:
    >
    >> Begin <878xrnw1jm.fsf@thalassa.informatimago.com>
    >> On 2006-03-07, Pascal Bourguignon wrote:
    >>> "nhk" writes:
    >>>> Is there a way I can retain the date of the original file in the
    >>>> compressed file. Like when I gunzip the zipped file it can give the
    >>>> date of the original file.
    >>>
    >>> Of course: use GNU tar!

    >>
    >> Why do you specifically mention gnu's not-so-compatible tar? Isn't this
    >> a normal feature of most if not all tars? I'd prefer star if the local
    >> tar isn't sufficient. The gnu tar implementation might be widely used,
    >> it is not universally used and neither is it universally compatible.

    >
    > Because I've specifically used GNU tar exclusively for fifteen years
    > on all the unix system I used, exactly for this reason.
    >
    > Some tar don't have -z or -j.
    > Some tar don't even have -f -, so you can write: gzip -d < $file | tar -xf -


    Which tar are those?

    f causes tar to use the next argument as the name of the
    archive instead of /dev/mt?. If the name of the file is
    `-', tar writes to standard output or reads from
    standard input, whichever is appropriate. Thus, tar can
    be used as the head or tail of a filter chain Tar can
    also be used to move hierarchies with the command
    cd fromdir; tar cf - . | (cd todir; tar xf -)

    That's from Unix v7. tar(1) was not present in Unix v6.

    > So either you have a lot of hard disk space and bear the inconvenience of typing:
    >
    > gzip -d $archive
    > tar xf $archive
    >
    > or
    >
    > tar cf ${file}.tar $file
    > gzip ${file}.tar
    >
    >
    >
    > or you download GNU tar once for all and type:
    >
    > tar zxf $archive
    >
    > or
    >
    > tar zcf ${file}.tar.gz $file


  11. Re: Compress (gzip) and move big file at the same time to different directoryon UNIX

    Jordan Abel writes:

    > On 2006-03-07, Pascal Bourguignon wrote:
    >> jpd writes:
    >>
    >>> Begin <878xrnw1jm.fsf@thalassa.informatimago.com>
    >>> On 2006-03-07, Pascal Bourguignon wrote:
    >>>> "nhk" writes:
    >>>>> Is there a way I can retain the date of the original file in the
    >>>>> compressed file. Like when I gunzip the zipped file it can give the
    >>>>> date of the original file.
    >>>>
    >>>> Of course: use GNU tar!
    >>>
    >>> Why do you specifically mention gnu's not-so-compatible tar? Isn't this
    >>> a normal feature of most if not all tars? I'd prefer star if the local
    >>> tar isn't sufficient. The gnu tar implementation might be widely used,
    >>> it is not universally used and neither is it universally compatible.

    >>
    >> Because I've specifically used GNU tar exclusively for fifteen years
    >> on all the unix system I used, exactly for this reason.
    >>
    >> Some tar don't have -z or -j.
    >> Some tar don't even have -f -, so you can write: gzip -d < $file | tar -xf -

    >
    > Which tar are those?
    > [...]
    > That's from Unix v7. tar(1) was not present in Unix v6.


    I've been told they exist. As I wrote, I've never used underdeveloped
    tars but to unpack GNU tar-${current_version}.tar.gz (Actually, I keep
    a untared copy of gzip and GNU tar for when I have to use a system
    when there's no gzip and no usable tar, but it's been a while since I
    needed it).


    --
    __Pascal Bourguignon__ http://www.informatimago.com/

    "You question the worthiness of my code? I should kill you where you
    stand!"

  12. Re: Compress (gzip) and move big file at the same time to different directoryon UNIX

    2006-03-6, 14:27(-08), nhk:
    > Thanks Stephane and Chris.
    >
    > Is there a way I can retain the date of the original file in the
    > compressed file.
    > Like when I gunzip the zipped file it can give the date of the original
    > file.

    [...]

    gzip < /here/file > /there/file.gz &&
    touch -r /here/file /there/file.gz

    gzip doesn't store the date in the compressed file. However,
    upon compressing and uncompressing it preserves the date of the
    original file (when used as gzip file, gunzip file.gz).

    --
    Stéphane

  13. Re: Compress (gzip) and move big file at the same time to different directoryon UNIX

    Begin <87wtf6vp0l.fsf@thalassa.informatimago.com>
    On 2006-03-07, Pascal Bourguignon wrote:
    > jpd writes:
    >> Why do you specifically mention gnu's not-so-compatible tar? Isn't this
    >> a normal feature of most if not all tars? I'd prefer star if the local
    >> tar isn't sufficient. The gnu tar implementation might be widely used,
    >> it is not universally used and neither is it universally compatible.

    >
    > Because I've specifically used GNU tar exclusively for fifteen years
    > on all the unix system I used, exactly for this reason.


    Ah, you're advocating your personal preference. I'd still rather use
    a standards compliant tar as gnu tar is such a great program that on
    gnu-only systems you have to use cpio to read POSIX tarballs, as despite
    opportunity, gnu tar doesn't support them. Which is probably why FreeBSD
    moved away from gnu tar. NetBSD and OpenBSD don't use it either, for
    that matter.


    --
    j p d (at) d s b (dot) t u d e l f t (dot) n l .
    This message was originally posted on Usenet in plain text.
    Any other representation, additions, or changes do not have my
    consent and may be a violation of international copyright law.

+ Reply to Thread