Help with gunzip


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with gunzip
# 8  
Old 06-06-2010
Java

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.

Code:
 
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:

Code:
 
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!
# 9  
Old 06-07-2010
Hi.
Quote:
Originally Posted by Arunprasad
My gunzip is successful but i lost the extension and i am also not able to read this unzipped dataset from SAS EG.
In a short test I wrote, gunzip did not restore the original extension. You can rename the file with:
Code:
mv test_run test_run.sas7bdat

the general idea being:
Code:
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
# 10  
Old 06-07-2010
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.

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

Please advise me!
# 11  
Old 06-07-2010
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:
Code:
#!/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:
Code:
% ./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

Last edited by drl; 06-07-2010 at 01:43 PM.. Reason: ( edit 1 - minor typos )
# 12  
Old 06-07-2010
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.

Last edited by Corona688; 06-07-2010 at 01:41 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

gunzip status

Hi, I'm trying to run my application on HP-UX server. I have to extract a *.tar.gz file. I'm doing that now in 2 steps. first I gunzip it and then pax it. My question is how can I check whether the data in the *.tar.gz file is corrupted or not?? Now, I'm trying to do this... (1 Reply)
Discussion started by: Kyaw Lwin Phyo
1 Replies

2. Shell Programming and Scripting

Gunzip files

Hi ALL, Am working with the gunzip command to zip all the old files having 10 days am using the command find . -name '*.log' -type f -mtime +10 -exec gunzip {} \; am facing two issues 1.)it displays the files which are all older than a year 2.)when am trying to gunzip all the... (2 Replies)
Discussion started by: thelakbe
2 Replies

3. SCO

gunzip problem

hi On one of our SCO 5.0.6 server gunzip doesn't work and I'm getting this error message: # gunzip dynamic linker: gunzip: symbol not found: ___requires_updated_system_library_se_ Killed What's missing? (0 Replies)
Discussion started by: ccc
0 Replies

4. Shell Programming and Scripting

Gunzip files

Hello Everyone, I have a few files in a directory such as : abc.xyz.txt1.gz abc.xyz.txt2.gz .... .... ... ... abd.xyz.txt100.gz And I want uncompressed files such as: abc.xyz.txt1 abc.xyz.txt2 .... ... ..... .... (1 Reply)
Discussion started by: ad23
1 Replies

5. UNIX for Dummies Questions & Answers

gunzip

I have a zip file as a.zip and it contains 1m xml files. like a1.xml, a2.xml.... The size is also very big nearly 1GB. I want to extract only a123.xml. Can any one help how can I do this? (1 Reply)
Discussion started by: siba.s.nayak
1 Replies

6. Shell Programming and Scripting

Help on gunzip

Hi All, I am using UNIX command to unzip the files gzip -d9 DW_*.gz The Xmls are compressed using gzip and it is received in the .gz format at UNIX box which need to be uncompressed. The above command is working fine for 400 compressed xmls(.gz files) but when the count becomes 401 or more i... (7 Replies)
Discussion started by: Codesearcher
7 Replies

7. UNIX for Dummies Questions & Answers

gunzip syntax help

Hi All, I am a newbie to unix and need help. I am trying to unzip the files in source library to destination library. the input filename can be any thing with abc and after unzip, i want the same file name with original extension suppose,the input file is ABC_jun25.dat.gz after gunzip in the... (1 Reply)
Discussion started by: onlyjayaram
1 Replies

8. UNIX for Dummies Questions & Answers

gunzip question

unzip test.zip ==> This uncompresses and keeps the original zip file. gunzip test.gz ==> Removes the .gz file after uncompressing. Is there any switch to make the .gz file available after uncompression. Thanx in advance. (3 Replies)
Discussion started by: devs
3 Replies

9. UNIX for Dummies Questions & Answers

Gunzip

Hi can't unzip a gz file in TurboLinux 7.0 when i'm trying this gunzip filename.tar.gz it always says not in gzip format what should I do...please help me (4 Replies)
Discussion started by: CreamHarry
4 Replies

10. UNIX for Dummies Questions & Answers

gunzip....problem

Hi........... i have downloaded...sunscreen3.1 lite frm sunfreeware .com and it is in tar.gz format..so i download gzip also... now pls tell me how to install gzip and how to unzip tht sunscreen tar.gz file..............after unzipping i have to untar the tar file or not.....pls tell me in... (2 Replies)
Discussion started by: Prafulla
2 Replies
Login or Register to Ask a Question