Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
--strip is unrecognized on the server that Im on. Looking for an answer still. –  Marc Aug 4 '09 at 17:48
    
My version of tar is 1.13.25 btw. –  Marc Aug 4 '09 at 17:53
    
Have a look at this answer –  hitautodestruct Oct 23 '12 at 7:57

3 Answers 3

up vote 10 down vote accepted

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.

share|improve this answer
    
I unchecked this as the answer because for some reason --strip isn't recognized. Any advice would be great. –  Marc Aug 4 '09 at 17:47
    
tar 1.14 was released over five years ago...surprising that some people don't have it yet –  davr Aug 5 '09 at 18:11

tar xvzf file.tar.gz -C /extract/point/

share|improve this answer
    
This does not do what I asked. Within the tar there is a root directory, I don't want that extracted, just everything under it. –  Marc Aug 4 '09 at 17:44
tar -xvzf file.tar.gz wordpress/*

will extract all the subdirectories (and files) of the wordpress folder into the current directory by creating a wordpress subdirectory. One way to "fool" the extraction by doing

ln -s . wordpress

and then running the tar extraction. The result will create each subfolder in the current folder because you linked the wordpress directory to the current directory.

Afterwards you can remove the wordpress symbolic link as it is no longer needed.

share|improve this answer
    
This is looking good. But the tar file has Wordpress/[LotsOfDirectories]. I'm updating my question. So, I want all the directories after Wordpress/ to be extracted and it looks like this sym link trick I would have to create a link for each of those directories? Is there another way? –  Marc Aug 5 '09 at 16:22
    
You should be able to use wordpress/* just as effectively as wordpress/directories and the symlink will still work since you're only trying to "redirect" the top level wordpress –  Kevin Kuphal Aug 5 '09 at 16:28
    
I updated my answer to reflect your update to the question –  Kevin Kuphal Aug 5 '09 at 16:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.