LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Extract tar file

[ILUG] Extract tar file

David De La Harpe Golden david at harpegolden.net
Fri Jan 30 18:23:18 GMT 2009


Conor Mac Aoidh wrote:
> Hi,
> 
> I have a question about extracting a tar file. This is what I have:
> 
> tar xvf filename.tar.bz2 -C /target
> 
> at the moment this creates a new folder and puts the contents in it,
> /target/filename/contents
>

Actually, technically, to clear up a confusion you probably have - the 
entry names *in the tar file itself* likely have a directory prefix 
"filename/" at the start, by convention. You could rename 
filename.tar.bz2 to supermonkey.tar.bz2 and you will find it would still 
expand to filename/contents

You can see this with
tar jtvf filename.tar.bz2

(contrast windoze where the standard - and thoroughly braindead - 
convention is to make entries in .zip files without the directory prefix 
so they infuriatingly expand into a big uncontained mess o' files by 
default)

It is quite possible to create tar archives without a such leading 
prefix in the
entries, but unix and linux folk will generally regard it as 
phenomenally annoying
except in limited circumstances where tar is being used as a filesystem
backup tool.

> how can i tell it to put the contents of the tar directly into that
> folder so they would be here: /target/contents
>

In effect, you want to drop one path component from the tarfile's 
entries. This is, despite my rant, common enough, so gnu tar and most 
unix tars have a "strip" option, in the gnu case:

tar jxvf filename.tar.bz2 -C /target --strip 1













More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell