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 tartar:
$ 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