Monday, May 13, 2024
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 4109  / 1 Year ago, sun, january 1, 2023, 12:48:15

I have a tar.gz which have pdfs in it I want to open a specific pdf without extracting it Is this possible using terminal through some command (I know we can do it using GUI but I want to use terminal)


More From » command-line

 Answers
1

To list (not-open) files in archive without extracting, run following command:



tar -tf myarchive.tar.gz


To extract and open directly run following command:



tar -xzf myarchive.tar.gz && evince *.pdf





For quick process: (extacted in /tmp/mypdf and then removed)



mkdir /tmp/mypdf && tar -xzf myarchive.tar.gz -C /tmp/mypdf && cd /tmp/mypdf && evince *.pdf && cd .. && rm -r mypdf


Where myarchive.tar.gz is your sample archive name.






For extracting specific file,



mkdir /tmp/mypdf && tar -xzf myarchive.tar.gz -C /tmp/mypdf "<file.pdf>" && cd /tmp/mypdf && evince *.pdf && cd .. && rm -r mypdf


where "<file.pdf>" is file-name of that specific file you want to extract & open.



Hope it is helpful. For advance function scripted command is useful by running script for specific purpose.


[#25170] Monday, January 2, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alliulet

Total Points: 46
Total Questions: 109
Total Answers: 97

Location: Svalbard and Jan Mayen
Member since Sat, Oct 10, 2020
4 Years ago
;