I am going crazy with a gzip file.
I can decompress the file in Windows using WinRAR but it is impossible on any UNIX operating system.
the file seems to be ok. If I do
file the_name_of_the_file.gzI get:
the_name_of_the_file.gz: gzip compressed data, from Unix, last modified: Sun Jan 30 14:10:21 2011But if I do
gunzip -f the_name_of_the_file.gzI alsways get:
gzip: the_name_of_the_file.gz: unexpected end of fileThe same problem happens when I try to extract the file using the GUI tool in Ubuntu or MacOSX,
Any ideas?
47 Answers
A workaround for uncompressing a file when gzip fails with "unexpected end of file" is to use zcat (also usually provided by the gzip package of your distribution).
$ zcat file.raw.gz > file.raw
Did you by any chance transfer the file from Win* to Unix via ftp in ascii mode? That may explain it. Is the file the same size on Win* and Unix?
1I suspect you're corrupting the file when copying it to the *nix machine.
FTP it in binary mode.
3I've solved the problem using the utility P7zip, a port of 7za.exe for POSIX systems.
1Based on a few experiences with WinRar, my first guess is that it's extracting incomplete or corrupted files without giving an error, while gzip is (correctly) giving an error.
What does 7zip make of your file?
What version does gzip -V announce?
What does gzip -t the_name_of_the_file.gz tell you? (probably the same unexpected EOF, but worth a try)
I had the same problem and, in my case, it was due to the fact that the file was an empty (0 bytes) gz file, created with the touch command:
$touch file.txt.gz
-rw-r--r-- 1 user user 0 2016-05-24 11:48 file.txtgzip could not decompress it, when called with the command:
$gzip -dv file.txt.gz
gzip: file.txt.gz: unexpected end of fileThe correct way to represent an empty txt file would have been generating first the txt file, then compress it and, finally, decompress it:
$touch file.txt
$gzip -v file.txt
file.txt: 0.0% -- replaced with file.txt.gz
$gzip -dv file.txt.gz
file.txt.gz: 0.0% -- replaced with file.txtI don't know if this scenario represents your case, but it may give you some clue or help somebody else.
Check if the destination has enough space where you want to copy the file. If still doesn't work try creating the file using 'touch' and give permission to 777 in the destination.
2