Unix. tar.gz. How to extract definite directory or file

At large backup file’s size not always there is a necessity to decompress all files, it’s quite enough to extract only one file or directory.

For that, it’s necessary to carry out next command:

tar -zxvf mytar.ball.tar.gz -C /tmp dir-name

At that it is necessary to indicate path to the directory where it has been stored in archive. You can see with help of next command:

tar -ztf backup.tar.gz |grep dir-name

Example

tar -zxvf mytar.ball.tar.gz -C /tmp www/domain.com/data/

Extracts directory content www/domain.com/data/ into directory /tmp

to top