You get a bonus - 1 coin for daily activity. Now you have 1 coin

How to Extract Specific Folders or Files from a tar Archive

Practice



This topic is a reminder for myself and others - how to extract specific files or folders from a tar archive without unpacking the whole archive, and also how to view the contents of an archive.


Contents of tar

tar:
$ tar -tf myfile.tar

tar.gz:
$ tar -ztf myfile.tar.gz

where instead of myfile.tar you specify the tar archive file, and correspondingly, instead of myfile.tar.gz - the tar.gz archive file.



Extract a specific file

$ tar -xf myfile.tar --file=file1 file2 file3

Here we extract the files file1, file2, and file3 from the archive.



Extract a specific folder

$ tar -xf myfile.tar mydirectory1/mysub1

In this example we recursively extract the directory mydirectory1/mysub1 and everything it contains.

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "LINUX operating system"

Terms: LINUX operating system