Linux – Un-tar a specific directory inside of a tar

directorylinuxtarWordpress

I have the WordPress tar, latest.tar.gz. Within it is the following structure
/wordpress/dirtories/files

When I do the following command I would prefer if I could have it unpack starting at /directories/ and not /wordpress with the goal of installing wordpress in the root of my html directory.

tar -xzvf latest.tar.gz

Is this possible?

UPDATE

Sorry, the tar contains /wordpress/[Directories] and I want all the directories in [Directories] extracted to the current directory. Sorry for misleading you all.

Best Answer

To strip down the parent directory:

tar zxvf latest.tar.gz --strip 1

If you want to be sure that nothing from the parent directory is extracted:

tar zxvf latest.tar.gz --strip 1 wordpress/directories

Edit:

--strip (--strip-path or --strip-components) was introduced in tar 1.14.