LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-05-2005, 06:52 AM   #1
xushi
Senior Member
 
Registered: Jun 2003
Location: UK
Distribution: Gentoo
Posts: 1,288

Rep: Reputation: 45
using tar to extract properly


Hi all,

I'm trying to figure out how to untar to a specific destination, similar to how 'installpkg' copies everything to its required destination

Say i tar cvvf /var/www/htdocs htdocs.tar
and i'm in my home folder now...
If i untar the file
tar xvvf htdocs.tar
it will be extracted to my current directory
/home/xushi/var/www/htdocs
instead of being moved to its propper destination
/var/www/htdocs

How can i solve this problem?
 
Old 03-05-2005, 06:57 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
if you're including the full file path inside the tar, you can extract the tar straight to the root directory, / which will implicitly put things in the right place.

Last edited by acid_kewpie; 03-05-2005 at 06:59 AM.
 
Old 03-05-2005, 06:58 AM   #3
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Did you try the -P option (--absolute-paths) when extracting, like

tar xvfP htdocs.tar
 
Old 03-05-2005, 06:59 AM   #4
xowl
Member
 
Registered: Jan 2005
Distribution: Slackware current (and others)
Posts: 188

Rep: Reputation: 30
First of all, I think U mean

tar cf htdocs.tar /var/www/htdocs

and second , what U R locking for is

tar xzf htdocs.tar -C /


Hope this work
 
Old 03-05-2005, 07:00 AM   #5
xushi
Senior Member
 
Registered: Jun 2003
Location: UK
Distribution: Gentoo
Posts: 1,288

Original Poster
Rep: Reputation: 45
If i also want to bzip it, would i do it this way?


tar cfj htdocs.tar.bz2 /var/www/htdocs

tar xzfjP htdocs.tar.bz2 -C /

EDIT:

No keefaz, i didn't try the -P option. i will compare both now.

EDIT: added P

Last edited by xushi; 03-05-2005 at 07:04 AM.
 
Old 03-05-2005, 07:03 AM   #6
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Try to put the option in this order (the f at least)

tar cjvf htdocs.tar.bz2 /var/www/htdocs
 
Old 03-05-2005, 07:07 AM   #7
xushi
Senior Member
 
Registered: Jun 2003
Location: UK
Distribution: Gentoo
Posts: 1,288

Original Poster
Rep: Reputation: 45
I keep getting this warning, i don't know if it affects anything i do or not

tar cjvf test.tar.bz2 /download/my.pls

tar: Removing leading '/' from member names

EDIT: This removal is the problem i'm facing.. I was wondering if there's anyway to disable that. So far, it works with the -C / option though.

Last edited by xushi; 03-05-2005 at 07:15 AM.
 
Old 03-05-2005, 07:51 AM   #8
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
I see, I would think the -P option can keep the leading '/' when taring
(I believed that this option was to be set during extracting but it seems rather
be used during taring)
 
Old 03-05-2005, 08:31 AM   #9
xushi
Senior Member
 
Registered: Jun 2003
Location: UK
Distribution: Gentoo
Posts: 1,288

Original Poster
Rep: Reputation: 45
Quote:
Originally posted by keefaz
I see, I would think the -P option can keep the leading '/' when taring
(I believed that this option was to be set during extracting but it seems rather
be used during taring)
From the testing i've just done.. Apparently you need to add the -P option on both tarring and untarring
 
Old 03-05-2005, 09:10 AM   #10
mdarby
Member
 
Registered: Nov 2004
Location: Columbus, Ohio
Distribution: Slackware-Current / Debian
Posts: 795

Rep: Reputation: 30
Tar:
tar czpf <tarball name> <Files to be tarred>

Untar:
tar zxf <tarball name> -C <Location>

To do Bzip, replace 'z' with 'j'
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
can not extract the tar.gz file sharad durgawad Linux - Software 3 10-05-2005 02:41 AM
extract .tar.bz2 EcceVery Debian 3 11-24-2004 12:39 PM
How to extract a tar.gz file? deWin Linux - Newbie 3 11-10-2004 11:24 AM
Choosing where to extract tar.gz Arclite Linux - Software 14 08-14-2003 03:57 PM
extract error tar.gz eye Linux - Software 6 05-18-2003 12:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration