Reputation: 1096
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.
Upvotes: 0
Views: 749
Reputation: 105
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
Upvotes: 0