Adding text to a compressed file without uncompressing

Bryan O'Neal Bryan.ONeal at TheONealAndAssociates.com
Thu Oct 31 12:28:05 MST 2013


I toke the small text and stream it into the other file using gzip -c
as mentioned above. Worked well I just could not see it through the
haze for ~30 min. Script works well and life is good - thanks for all
the reply's.

On Thu, Oct 31, 2013 at 9:16 AM, Matt Graham <mhgraham at crow202.org> wrote:
>> On Oct 31, 2013 1:40 AM, "Bryan O'Neal"
>>>
>>> So let's say I have a few hundred lines of text I need at the beginning
>>>
>>> or end of a big compressed text file. Say a 20GB uncompressed / 4GB
>>> compressed JSON or XML doc. Now lets say I have no desire to
>>> uncompress this file and I have no desire to use interactive tools
>>>
>>> like vim. How could I achieve this?
>
>
> What compression method are you using?  (Storing that much data in one XML
> file seems like a total organizational failure to me, too.)
>
> I don't think you can do this with zip, not sure about lzma, but I would
> guess "not ever at the start of the file for any commonly-used compression
> method".  Data compression's weird like that.
>
> You can do a bit of appending if you're using gzip:
>
> gzip -c file.txt > foo.gz
> gzip -c file2.txt >> foo.gz
> gzip -dc < foo.gz
>
> (decompresses foo.gz to stdout, you will get file.txt followed by file2.txt)
>
>
> Stephen wrote:
>>
>> Tar has a built in append feature so you can add files to the archive
>
>
> tar will refuse to append things to compressed archives.
>
> --
> Crow202 Blog: http://crow202.org/wordpress
> There is no Darkness in Eternity
> But only Light too dim for us to see.
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss


More information about the PLUG-discuss mailing list