Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

gzip -d to new file? 1

Status
Not open for further replies.

dstevens66

Programmer
Dec 7, 2005
15
0
0
US
I want to unzip a compressed file to another file in another directory.

I thought I could use:

gzip -d /folder/datafile.dat.gz > /otherfolder/newfile.dat

where newfile.dat would have the uncompressed contents of datafile.dat.gz. I want datafile.dat.gz to remain unchanged.

When I try the command I wrote above, I get an empty /otherfolder/newfile.dat. I know there are some lines of data in /folder/datafile.dat.gz. The file datafile.dat.gz is now datafile.dat.

I'm not a unix scripting guru (obviously) hopefully there is something simple I'm missing. thanks
 
Thanks! That did it!

I don't know if anyone help with this -

when I do the unzipping, the new file is full of junk characters instead of the actual data from the zipped file.

If /folder/datafile.dat.gz contains '20070905 10'

the unzipped contains something like ^_\213^H^H\212\253\341F^Cdatafile.dat.gz\223\357\346\340\350Z\

Note the name of the file is included with the junk. But it looks like none of the data from inside the file is included. Any ideas?
 
The problem you are having now is this:

Since the original file was created with a simple "gzip filename.ext", the very beginning of the gzip has a small amount of header data. When you do a direct extraction, you're also extracting that header; if you were to just do a "gunzip filename.ext.gz", that header would not be included in the resulting file.

If you've got the space, copy the original .gz to another directory, then just do a normal gunzip on the file.
 
I'd try

gzip -dc filename.ext.gz >/path/to/filename.ext

or

gunzip -c filename.ext.gz >/path/to/filename.ext



HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top