Shell – View a file in a tar archive without extracting it

archiveshell-scripttar

I want to view the content of the tarred file without extracting it,
Scenario: I have a.tar and inside there is a file called ./x/y.txt. I want to view the content of y.txt without actually extracting the a.tar.

Best Answer

It's probably a GNU specific option, but you could use the -O or --to-stdout to extract files to standard output

$ tar -axf file.tgz foo/bar -O
Related Question