Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

The Situation

I am extracting a CMS from drupal-7.15.tar.gz to /var/www.

When extracted normally (with tar -xvzf filename.tar.gz) the files end up in /var/www/drupal-7.15/

The Goal

I want the contents from the archived drupal-7.15/ directory to extract directly into /var/www

share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted

Use

 tar -xvzf filename.tar.gz --strip-components=1

--strip-components=1 tells tar to strip the first path component (the drupal-7.15/ in your case) from each file when unpacking.

share|improve this answer
    
Absolutely brilliant. Thanks, Florian. –  bitfed Sep 20 '12 at 8:14
add comment

The simplest and more user-friendly solution is to open nautilus using:

gksudo nautilus

Then head to your archive, double click it, wiat for it to open with the archive manager, double click into the directory (inside the archive manager, hit Ctrl+A so as to select all the files inside the directory, click on the "Extract" button, and then select /var/www/

Alternatively, you can just

sudo mv /var/www/drupal-7.15/* /var/www/
sudo rm -r /var/www/drupal-7.15
share|improve this answer
add comment

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.