Home > Net >  Print a file content from a tar.gz archive
Print a file content from a tar.gz archive

Time:02-17

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.

CodePudding user response:

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.

CodePudding user response:

The following will extract that one file and write it to stdout

tar --extract -O --file=openjdk-17.0.2_linux-aarch64_bin.tar.gz jdk-17.0.2/release

I do not know how you print on your system but you can pipe the output to lp if that is set up.

tar --extract -O --file=openjdk-17.0.2_linux-aarch64_bin.tar.gz jdk-17.0.2/release | lp
  • Related