Search code examples
linuxcompressionextractarchivesparse-matrix

how to check the actual size of archived file without extracting it?


I've got an archive foo.tar.gz(8M of actually size), which contains a large sparse file(around 10G) in it.

My question is, how could I know the actual sparse file size without extracting the archive?


Solution

  • tar ztvf foo.tar.gz
    

    would list the contents of the file without extracting.

    The --totals option causes tar to print on the standard error the total amount of bytes transferred when processing an archive.

    tar ztvf foo.tar.gz --totals
    

    would return the total number of bytes read (essentially the size of the archive after extracting).

    If you are looking for a particular file in the archive, say of the pattern FOOBAR,

    tar ztvf foo.tar.gz -v --wildcards '*FOOBAR*'
    

    would list the matching file(s) that would contain the size.