LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-21-2006, 02:22 AM   #1
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,637

Rep: Reputation: 54
About tar command


Hi folks,

I have been looking around on man tar and can't resolve what option shall be up on running;

tar jcpf tarball.tar.bz2 /path/to/tar/

to exclude the directories '/path' and 'to' on the compressed tarball only retaining '/tar directory.

Please advise. TIA


B.R.
satimis
 
Old 12-21-2006, 02:41 AM   #2
Nathanael
Member
 
Registered: May 2004
Location: Karlsruhe, Germany
Distribution: debian, gentoo, os x (darwin), ubuntu
Posts: 940

Rep: Reputation: 32
it will not include contents of /path and /path/to, but will keep the relative path of tar. as you are telling tar with /path/to/tar to make an archive of that folder it will keep the that info to know where to extract the folder tar to.
if you only want the archive to hold ./tar then do
cd /path/to
tar jcpf /path/to/archive/tarball.tar.bz2 tar
 
Old 12-21-2006, 02:51 AM   #3
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
...from the tar manpage:
Code:
tar -cvvf foo.tar foo/
              tar contents of folder foo in foo.tar
so: tar -cvvf bar.tar foo/bar/ will tar the content of the bar folder
... but tar -cvvf foo.tar foo/bar (i.e. leave off the trailing "/")should give you the bar folder itself, as well. (Directories are files too.)

You have tried this of course...

Last edited by Simon Bridge; 12-21-2006 at 02:56 AM.
 
Old 12-21-2006, 02:58 AM   #4
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,637

Original Poster
Rep: Reputation: 54
Hi Nathanael,

Tks for your advice.

Quote:
it will not include contents of /path and /path/to, but will keep the relative path of tar. as you are telling tar with /path/to/tar to make an archive of that folder it will keep the that info to know where to extract the folder tar to.
if you only want the archive to hold ./tar then do
cd /path/to
tar jcpf /path/to/archive/tarball.tar.bz2 tar
I don't want to retain the complete path after decompresing;

/path/to/tar/

After decompression I expect only to have;

/tar

Neither I need to compress the contents on /path and /path/to/

Can I hold the compressed tarball on another directory instead of on /path/to/tar/

Tks.


B.R.
satimis
 
Old 12-21-2006, 05:19 AM   #5
Nathanael
Member
 
Registered: May 2004
Location: Karlsruhe, Germany
Distribution: debian, gentoo, os x (darwin), ubuntu
Posts: 940

Rep: Reputation: 32
if you had read what i wrote you would have seen that the last 2 lines of my post address exactly what you need to do to archieve that!!!

cd to the parent directory
and with /path/to/archive/tarball.tar.bz2 you specify where you want you archive to be saved - ie replace /path/to/archive with /root and you will find a file tarball.tar.bz2 in /root!!!!!

by cd'ing into the parent directory (cd /path/to ) and then taring ./tar you will also only have a record for ./tar in your archive and not ./path/to/tar...

give it a shot and see what it does!!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 03:48 AM
tar command.. johnyy Linux - Software 4 12-31-2003 11:54 PM
Tar command satimis Linux - Newbie 3 11-03-2003 11:34 PM
Tar command Rig24 Linux - General 5 04-18-2003 09:47 PM
tar command gogo Linux - General 4 11-17-2001 10:53 AM


All times are GMT -5. The time now is 04:18 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration