7

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.

l0c0b0x
  • 11,867
  • 7
  • 47
  • 76
Marc
  • 405
  • 2
  • 5
  • 11

3 Answers3

13

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.

Dan Carley
  • 25,617
  • 5
  • 53
  • 70
  • I unchecked this as the answer because for some reason --strip isn't recognized. Any advice would be great. – Marc Aug 04 '09 at 17:47
  • tar 1.14 was released over five years ago...surprising that some people don't have it yet – davr Aug 05 '09 at 18:11
0

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

Yordan
  • 106
  • 3
  • 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 04 '09 at 17:44
0
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.

Kevin Kuphal
  • 9,134
  • 1
  • 35
  • 41
  • 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 05 '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 05 '09 at 16:28