This question already has an answer here:

Can somebody help me to figure out a command to find a file recursively that is embedded in a tgz file which is within another tgz files recursively:


My goal is to be able to list abc.txt without extracting MainFile.tgz nor SubFileX.tgz.

The command below is only listing the first level of files (i.e. SubFile.tgz); therefore the grep command cannot find abc.txt in the list:

tar tvf MainFile.tgz | grep abc

marked as duplicate by Gilles files Apr 8 '16 at 22:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


You need to extract them, but you don't need to store them on the disk :

tar -xOf MainFile.tgz SubFile1.tgz | tar -xO SubFile2.tgz | tar -xO SubFile3.tgz | tar -x abc.txt

The -O flags sets output to stdout and without -f tar will accept archive data from stdin.

Not the answer you're looking for? Browse other questions tagged or ask your own question.