How can I recover files from a corrupted .tar.gz archive?

后端 未结 3 1148
说谎
说谎 2021-02-02 09:03

I have a large number of files in a .tar.gz archive. Checking the file type with the command

file SMS.tar.gz

gives the response



        
3条回答
  •  面向向阳花
    2021-02-02 09:32

    Here is one possible scenario that we encountered. We had a tar.gz file that would not decompress, trying to unzip gave the error:

    gzip -d A.tar.gz
    gzip: A.tar.gz: invalid compressed data--format violated
    

    I figured out that the file may been originally uploaded over a non binary ftp connection (we don't know for sure).

    The solution was relatively simple using the unix dos2unix utility

    dos2unix A.tar.gz
    dos2unix: converting file A.tar.gz to UNIX format ...
    tar -xvf A.tar
    file1.txt
    file2.txt 
    ....etc.
    

    It worked! This is one slim possibility, and maybe worth a try - it may help somebody out there.

提交回复
热议问题