In a data load, we receive some zipped files (*.gz) I found that when you use the regular extraction:
gzip.exe -d -f "foo.csv.gz"
The “foo.csv.gz” file will automatically be deleted by gzip and replace it with “foo.csv”
However, if we are archiving these csv files it will take up a fair bit more space, so we wanted to just store the archived version of the flat file.
Originally I thought that I was going to need to unzip them, then rezip all of the files at the end of the process to get the files ready for archival but this took was just a lot of extra processing.
Finally I came across a way to avoid the deletion of the file If you output the file to standard out you are able to then redirect that output stream into your output file (without affecting the original .gz file).
gzip.exe -d -f -c "foo.csv.gz" > foo.csv
This will take all of the contents from the gz file and push it to STDOUT and then with using the >, we redirect the information written to STDOUT to the CSV file where we need it.
Hope this helps
Information based on post from a member on Stack Overflow: http://stackoverflow.com/questions/7351887/gzip-extracting-without-deleting-zip-file