Scenario : How do you extract a single folder from a large tar.gz archive?
In this testing scenario i have a tarball archive by the name techsuccor.tar.gz which has a directory named html within it which i need to extract without extracting other files or directory from the archive
Resolution : This can be done in simple 2 steps
Step1 : First always check the content of your archive which you have made which will show you correct path of the directory which you are looking to extract from the archive, as shown in below command.
# tar -tvf techsuccor.tar.gz
Sample Output of above command :
In the above output as you can see there is one directory by the name html which has the path techsuccor/var/www/html
Step2 : Now as we know the exact path of the directory we wish to extract from the tarball we have to use the same for extracting as shown in below command
# tar -xvf techsuccor.tar.gz techsuccor/var/www/html/
ar stores relative path and hence as shown in Note :1 the html directory wont be created in your present working directory instead it will create all the folders present above the html folder in the archive as shown in Note :2