5

Can i concatenate two already gzipped files (using gzip) and then gunzip them? As of today, I download the gzipped files from remote servers, gunzip them individually and then cat them to merge. Looking to make things faster here by merging the gzipped files and then gunzipping.

Mark Adler
  • 101,978
  • 13
  • 118
  • 158
Pradeep
  • 109
  • 5
  • why not just `zcat file1.gz file2.gz` ? that command sends the uncompressed contents of both files to zcat's stdout one after the other – fvu Nov 18 '16 at 17:03
  • Well I was wondering: as you tagged your question with zcat I thought that maybe zcat had some issue that you didn't want.. But ok, problem solved, good! – fvu Nov 18 '16 at 19:39

1 Answers1

2

Yes. The concatenation of gzip streams is also a valid gzip stream. The result of gunzipping is the concatenation of the uncompressed data.

Michael
  • 41,989
  • 11
  • 82
  • 128
Mark Adler
  • 101,978
  • 13
  • 118
  • 158