Shell – tar: Unexpected EOF in archive

centosgzipshelltar

I was attempting to untar a .tar.gz file, but came across this error:

gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now

The tar.gz file includes a .tar file, which when untarred results in:

tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now

I tried both –ignore-zeros and –ignore-failed-read, although they both didn't work.

Is there any way I could extract this file even if it is corrupted?

The file type in question: .tar.gz: Gzip Compressed Data, from a UNIX system.

Best Answer

Check two items:

(1) Is the FILE INCOMPLETE due to a faulty download? Re-download, and use the -c option if your are using wget. (happens all the time).

(2) Does the .tar or .tar.gz filename have ILLEGAL CHARACTERS. It's best to keep archive names simple, short, composed of letters and numbers. (happens all the time). So just rename the file. This one nailed me recently as I thought it would be convenient to include a time/date stamp as part of the archive name. BAD IDEA!

Related Question