Help with gunzip

Hi All,

I have a file "HOTEL_INFO.zip" and getting the below errors:

 
server1:/home/arun# gunzip -S .zip HOTEL_INFO.zip
gunzip: HOTEL_INFO.zip: first entry not deflated or stored -- use unzip

 
server1:/home/arun#unzip HOTEL_INFO.zip
ksh: unzip:  not found.
 
server1:/home/arun#gunzip HOTEL_INFO.zip
gunzip: HOTEL_INFO.zip: unknown suffix -- ignored

i believe this is something we play around with ulimit.

server1:/home/arun# ulimit -a
time(seconds) unlimited
file(blocks) 2097151
data(kbytes) 131072
stack(kbytes) 32768
memory(kbytes) 32768
coredump(blocks) 2097151
nofiles(descriptors) 2000

and changing the attribute file = unlimited will resolve the purpose and so i can gunzip the .zip file using the below command successfully:

 server1:/home/arun# gunzip -S .zip HOTEL_INFO.zip 

Please advise whether ulimit -f unlimited is the appropriate command as to execute from 'root' id? since i dont have authorization to perform this action.

Or advise me, which is the appropritae command/what actually restricting me from ding this?

FYI, the user id here is LDAP maintained and not local.

Thanks.

gunzip will uncompress the file which was previously compressed with gzip, and has a ".gz'' extension.
The !gunzip Command: Uncompress Files

.zip file can be unzipped in other ways. Which OS are you using?

Hi Hari,

Thanks a lot for the info!
It seems the !gunzip also works with ".gzip" or ".gz" file. And i surfed around and found that

gunzip -S .zip HOTEL_INFO.zip

this command will work but got error.

I believe this is something i need to do with ulimit. i suspect that i need to change the file(blocks) unlimited by the command:

ulimit -f unlimited

correct me if i am wrong and also advise how a root id can perform this change to unlimited (using what command) and advise is tere any other way to get it done.

Thanks!

From the gunzip, man page,

      Files created by zip can be uncompressed by gzip only if they have a
      single member compressed with the 'deflation' method. This feature is
      only intended to help conversion of tar.zip files to the tar.gz
      format.  To extract a zip file with a single member, use a command
      like gunzip <foo.zip or gunzip -S .zip foo.zip.  To extract zip files
      with several members, use unzip instead of gunzip.

you seems to be root, its easy to install unzip.
Or check if its available on any other server (probably linux) . If so, ftp the file, extract it with unzip and zip again with gzip. and send back to the server1.

If you have java installed on ur server you can use ' jar' to unzip the .zip file:

Ex: /opt/java1.5/bin/jar �xvf HOTEL_INFO.zip

Hi All,

Really thanks a lot for your help!
I think i have diverted you. Here is the output for your suggestions:

  1. server1:/home/arun# gunzip < HOTEL_INFO.zip
    gunzip: stdin: first entry not deflated or stored -- use unzip

i am not root user and i am not able to install unzip. i thought if i change file(blocks) listed in ulimit -a to be 'unlimited' then i can run the above gunzip commands. So to achieve this is the following command is correct?

ulimit -f unlimited

but to execute this command i dont have access. Only root can perform. So just curious to know how a root user will perform this change. Please advise.

  1. Sorry, i dont have java.

Please help me... Thanks again!

---------- Post updated 06-04-10 at 03:33 PM ---------- Previous update was 06-03-10 at 07:04 PM ----------

Hi Al,,

I have one more question...

when i am able to create a file around 10GB then why such unzip/gunzip is not allowing me to perform even the file is less than 4GB .... (the data are just an example) and say expanding the zipped file will be 10 GB which is originally i created.... it should not be that my original size and this ulimit size should be same?

please advise me on this also.

Hi.

If you are comfortable downloading programs, p7zip may be of interest to you. In almost all *nix systems you can have local programs -- in your HOME directory structure -- you do not need to install them in system areas.

Here's an example of creation of a zip file and extraction with p7zip (for me, p7zip was in my Debian repository):

#!/usr/bin/env bash

# @(#) s1	Demonstrate uncompress, extract of zip archive with p7zip.
# 7zip: http://p7zip.sourceforge.net/

pe() { for i;do printf "%s" "$i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }

rm -f t1 t2 t1.zip
FILE=${1-data1}

pl " Data file $FILE:"
head -20 $FILE

pl " Created zip file:"
cp $FILE t1
zip t1.zip t1
file t1.zip
ls -lgG t1 t1.zip

pl " Unzip with 7z:"
7z e -so t1.zip > t2
ls -lgG t2

pl " Compare files:"
if cmp --quiet t1 t2
then
  pe " Files have identical content."
else
  pe " Files differ, details:"
  diff t1 t2
fi

exit 0

producing:

% ./s1

-----
 Data file data1:
Albuquerque, N.M.
Arlington, Texas
Atlanta, Ga.
Austin, Tex.
Baltimore, Md.
Boston, Mass.
Charlotte, N.C.
Chicago, Ill.
Cleveland, Ohio
Colorado Springs, Colo.

-----
 Created zip file:
  adding: t1 (deflated 21%)
t1.zip: Zip archive data, at least v2.0 to extract
-rw-r--r-- 1 160 Jun  4 09:37 t1
-rw-r--r-- 1 262 Jun  4 09:37 t1.zip

-----
 Unzip with 7z:

7-Zip  4.58 beta  Copyright (c) 1999-2008 Igor Pavlov  2008-05-05
p7zip Version 4.58 (locale=C,Utf16=off,HugeFiles=on,1 CPU)

Processing archive: t1.zip

Extracting  t1

Everything is Ok

Size:       160
Compressed: 262
-rw-r--r-- 1 160 Jun  4 09:37 t2

-----
 Compare files:
 Files have identical content.

See the sourceforge URL noted in the script. Best wishes ... cheers, drl

Hi drl,

thanks a lot for ur info! i am not upto to what you have updated....

i played around and got where the problem is:
I have a dataset file copied in Windows called test_run.sas7bdat and zipped it and transferred to Unix box using WinSCP.

 
server1:/home/arunpr# ls -lrt
-rw-r-----    1 arunpr   user            3647 Jun 06 07:37 test_run.zip
server1:/home/arunpr# gunzip test_run.zip
gunzip: test_run.zip: unknown suffix -- ignored
server1:/home/arunpr# gunzip -S .zip test_run.zip
server1:/home/arunpr# ls -lrt
-rw-r-----    1 arunpr   user           23784 Jun 06 07:37 test_run

My gunzip is successful but i lost the extension and i am also not able to read this unzipped dataset from SAS EG.

Please advise how to get the dataset normally when i do this kind of gunzip... is there any more option need to be included?

And one more scenario:
I have one more file (which is my friend kept in my work area and not sure what method he used to transfer/load that .zip file to unix box) which is 354258928 Bytes in size and when i perform the same gunzip options i am getting the below error:

 
server1:/home/arunpr# gunzip -S .zip HILTON.zip
gunzip: HILTON.zip: first entry not deflated or stored -- use unzip

Is that size is restricting me or my friend copied in different way which corrupted this zip file?

Please advise me on this also...

Thanks!

Hi.

In a short test I wrote, gunzip did not restore the original extension. You can rename the file with:

mv test_run test_run.sas7bdat

the general idea being:

mv old-name new-name

If that allows sas to run, then perhaps we can move on to other questions you have asked ... cheers, drl

Hi drl,

Thats a great idea!

the rename worked for me.... sas able to read the dataset without any issues.

The actual .zip file what i have is 337 MB in size then probably it will be more than a GB when unzip the the same (not sure).

And i am not sure why i am not able to perform the below and getting the error.... is this because the file size constraint? and i have enough space in the file system too.

server1:/home/arunpr# gunzip -S .zip HILTON.zip
gunzip: HILTON.zip: first entry not deflated or stored -- use unzip

Please advise me!

Hi.

The gunzip command, like most of the *nix commands, does one thing well. In the case of gzip / gunzip, that is compressing / uncompressing files. It does not gather files together like many Windows utilities, zip, winzip, pkzip, etc. In the *nix world, the gathering is done with a separate utility, the most common being tar.

So the usual method of working in *nix is run tar to get a single file of a collection of files, and then, as a separate step, compress that file. The result is often a name that looks like name.tar.gz.

The gunzip command, as a convenience, will uncompress a zip file, but only if it has a single element. The way that gunzip works is to uncompress the file to a temporary file, and (effectively) copy that file back onto the name.zip file, so the original file is essentially replaced. Other utilities allow the name.zip file to remain, and create additional files that were in the archive. Both the commands unzip and 7z work like that.

So if one has a zip archive with more than one element, one needs to:

a) use a command different from gunzip, or

b) re-create the zip archive with single elements.

I quickly wrote a script that illustrates many of the topics we have discussed:

#!/usr/bin/env bash

# @(#) s0	Demonstrate file extension issues with unzip, gunzip, 7z.
# 7zip: http://p7zip.sourceforge.net/

pe() { for i;do printf "%s" "$i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }
# export PATH="/usr/local/bin:/usr/bin:/bin"
version >/dev/null 2>&1 && version "=o" unzip 7z && gunzip -V | head -1

rm -f t1 t1.zip t1.sas7bdat t2 t2.zip t2.sas7bdat 
FILE=${1-data1}

pl " Data file $FILE:"
head -20 $FILE

pl " Create zip files with more than one element:"
rm -f t1.zip t1.sas7bdat t2.sas7bdat
cp $FILE t1.sas7bdat
cp $FILE t2.sas7bdat
zip t1.zip t1.sas7bdat t2.sas7bdat
file t1.zip
ls -lgG t1.sas7bdat t2.sas7bdat t1.zip

pl " unzip with gunzip, expect failure, more than one element in archive":
rm -f t1.sas7bdat t2.sas7bdat
gunzip -S .zip t1.zip
ls -lgG t*

pl " unzip with 7z, expect success with multiple elements:"
rm -f t1.zip t1.sas7bdat t2.sas7bdat
cp $FILE t1.sas7bdat
cp $FILE t2.sas7bdat
zip t1.zip t1.sas7bdat t2.sas7bdat
file t1.zip
rm -f t1.sas7bdat t2.sas7bdat
ls -lgG t*
7z x t1.zip
ls -lgG t*

pl " Re-create zip file with only one element:"
rm -f t1.zip t1.sas7bdat t2.sas7bdat
cp $FILE t1.sas7bdat
zip t1.zip t1.sas7bdat
file t1.zip
ls -lgG t1.sas7bdat t1.zip

pl " unzip with unzip (keeps t1.zip):"
zip t1.zip t1.sas7bdat
rm t1.sas7bdat
unzip t1.zip
ls -lgG t1.sas7bdat t1.zip

pl " unzip with gunzip (removes t1.zip, loses extension):"
gunzip -S .zip t1.zip
ls -lgG t1*

pl " Unzip with 7z (keeps t1.zip):"
rm -f t1.zip t1.sas7bdat
cp $FILE t1.sas7bdat
zip t1.zip t1.sas7bdat
rm t1.sas7bdat
7z x t1.zip
ls -lgG t1.sas7bdat t1.zip

exit 0

producing:

% ./s0
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution        : Debian GNU/Linux 5.0 
UnZip 5.52 of 28 February 2005, by Debian. Original by Info-ZIP.
7z - ( /usr/bin/7z Jun 21 2008 )
gzip 1.3.12

-----
 Data file data1:
Albuquerque, N.M.
Arlington, Texas
Atlanta, Ga.
Austin, Tex.
Baltimore, Md.
Boston, Mass.
Charlotte, N.C.
Chicago, Ill.
Cleveland, Ohio
Colorado Springs, Colo.

-----
 Create zip files with more than one element:
  adding: t1.sas7bdat (deflated 21%)
  adding: t2.sas7bdat (deflated 21%)
t1.zip: Zip archive data, at least v2.0 to extract
-rw-r--r-- 1 160 Jun  7 08:23 t1.sas7bdat
-rw-r--r-- 1 538 Jun  7 08:23 t1.zip
-rw-r--r-- 1 160 Jun  7 08:23 t2.sas7bdat

-----
 unzip with gunzip, expect failure, more than one element in archive:
gzip: t1.zip has more than one entry -- unchanged
-rw-r--r-- 1 538 Jun  7 08:23 t1.zip

-----
 unzip with 7z, expect success with multiple elements:
  adding: t1.sas7bdat (deflated 21%)
  adding: t2.sas7bdat (deflated 21%)
t1.zip: Zip archive data, at least v2.0 to extract
-rw-r--r-- 1 538 Jun  7 08:23 t1.zip

7-Zip  4.58 beta  Copyright (c) 1999-2008 Igor Pavlov  2008-05-05
p7zip Version 4.58 (locale=C,Utf16=off,HugeFiles=on,1 CPU)

Processing archive: t1.zip

Extracting  t1.sas7bdat
Extracting  t2.sas7bdat

Everything is Ok

Files: 2
Size:       320
Compressed: 538
-rw-r--r-- 1 160 Jun  7  2010 t1.sas7bdat
-rw-r--r-- 1 538 Jun  7 08:23 t1.zip
-rw-r--r-- 1 160 Jun  7  2010 t2.sas7bdat

-----
 Re-create zip file with only one element:
  adding: t1.sas7bdat (deflated 21%)
t1.zip: Zip archive data, at least v2.0 to extract
-rw-r--r-- 1 160 Jun  7 08:23 t1.sas7bdat
-rw-r--r-- 1 280 Jun  7 08:23 t1.zip

-----
 unzip with unzip (keeps t1.zip):
updating: t1.sas7bdat (deflated 21%)
Archive:  t1.zip
  inflating: t1.sas7bdat             
-rw-r--r-- 1 160 Jun  7 08:23 t1.sas7bdat
-rw-r--r-- 1 280 Jun  7 08:23 t1.zip

-----
 unzip with gunzip (removes t1.zip, loses extension):
-rw-r--r-- 1 160 Jun  7 08:23 t1
-rw-r--r-- 1 160 Jun  7 08:23 t1.sas7bdat

-----
 Unzip with 7z (keeps t1.zip):
  adding: t1.sas7bdat (deflated 21%)

7-Zip  4.58 beta  Copyright (c) 1999-2008 Igor Pavlov  2008-05-05
p7zip Version 4.58 (locale=C,Utf16=off,HugeFiles=on,1 CPU)

Processing archive: t1.zip

Extracting  t1.sas7bdat

Everything is Ok

Size:       160
Compressed: 280
-rw-r--r-- 1 160 Jun  7  2010 t1.sas7bdat
-rw-r--r-- 1 280 Jun  7 08:23 t1.zip

Best wishes ... cheers, drl

in short: gunzip is not unzip. they are not the same command. gunzip is related to zip only by ancestry, for .zip files use unzip. for gz files use gunzip. If you don't have unzip, get it, your OS and distribution is all but guaranteed to have the most ported program on the planet.