Extract specific file from gzipped archive

It is very usefull to know how to exact a certain file or subfolder from a gzipped archive.

You can browse the archive with vim and see exactly what files and subfolders are in the archive. To browse in a subfolder contained by an archive, double click on that subfolder from the archive, in the vim instance.

$ vim archive.tar.gz

Let’s assume that we have in the archive the files file1 file2 and the subfolders sub1 and sub2 containing file3 and file4 (sub1/file3 and sub2/file4).

I will show you how to exact file1 from the archive and sub2/file4, from the sub2 directory.

Exact file1:
$ tar --extract --file=archive.tar.gz file1

Exactract sub2/file4:
$ tar --extract --file=archive.tar.gz sub2/file4

To exact certain files from subfolders inside archive, use only relative paths.

this is the proof that my method works: test.

Liked it? Take a second to support Geekster on Patreon!
Tagged with: , , , , ,
Posted in The Linux and Unix Articles!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Support LinuxG via Patreon
Support LinuxG.net on Patreon!
Subscribe

  

Subscribe to get the latest Linux news and how to guides directly on your e-mail!