Search code examples
linuxbashtararchive

Print a file content from a tar.gz archive


I would like to print a single file content from a tar.gz archive.

I know I can list the files from the archive like so:

$ tar -tf openjdk-17.0.2_linux-aarch64_bin.tar.gz
[...snip...]
jdk-17.0.2/lib/server/libjsig.so
jdk-17.0.2/lib/server/libjvm.so
jdk-17.0.2/lib/src.zip
jdk-17.0.2/lib/tzdb.dat
jdk-17.0.2/release      <---- print the content of this file (with 'cat' or 'more')

I want to print the content of the file jdk-17.0.2/release, preferably without extracting it if possible.


Solution

  • You can use vim instead, and then browse using your cursor:

    vim openjdk-17.0.2_linux-aarch64_bin.tar.gz
    

    Alternatively, have a look at this thread.