LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 06-25-2009, 03:29 PM   #1
canadatom
LQ Newbie
 
Registered: Jun 2009
Posts: 2

Rep: Reputation: 0
how to run tar wtihout re-create folders


Hello everyone,

I have a tar.gz file containing many sub-folders, I am trying to untar the file so all the files in sub-folders will be extracted into the one folder, I know how to use ubuntu tar GUI program to do it by uncheck option called re-create folders, but how can I do it in shell by using tar command?
tar -xvf name.tar.gz will re-create folders by default, I don't see any option to override this, anyone can help?

Thanks,

Tom
 
Old 06-25-2009, 10:04 PM   #2
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,191

Rep: Reputation: 105Reputation: 105
Check `info tar`. The following does something like you ask:

Quote:
`--strip-components=NUMBER'
Strip given NUMBER of leading components from file names before
extraction.(1) For example, if archive `archive.tar' contained
`/some/file/name', then running

tar --extract --file archive.tar --strip-components=2

would extracted this file to file `name'.
but, your version of tar may vary, and that option was previously called `--strip-path'.
 
Old 06-25-2009, 11:05 PM   #3
vap16oct1984
Member
 
Registered: Jun 2009
Location: INDIA
Distribution: RHEL-5
Posts: 174
Blog Entries: 3

Rep: Reputation: 38
To extract an entire archive, specify the archive file name only, with no individual file names as arguments. For example,

$ tar -xvf collection.tar

produces this:

-rw-rw-rw- me user 28 1996-10-18 16:31 jazz
-rw-rw-rw- me user 21 1996-09-23 16:44 blues

You can now extract the member `blues' from the archive file `collection.tar' like this:

$ tar --extract --file=collection.tar blues
 
Old 06-26-2009, 02:47 PM   #4
canadatom
LQ Newbie
 
Registered: Jun 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Here is the solution I used in this case:

1. Shell script:
Code:
tar -xzvf tarball
find . -type -exec mv -f {} . \;
2.
Code:
7z e filename.tar.gz
Thanks for helping

Tom
 
  


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 to create .diff.gz/.dsc/.orig.tar.gz from a downloaded tar.gz application? frenchn00b Linux - General 4 05-18-2008 10:09 AM
tar multiple folders and files at once sinister1 Linux - General 4 12-10-2007 03:49 AM
Create a subfolder in several folders [FragMax]genesis Linux - Newbie 3 10-13-2006 10:17 PM
Samba can create new files and folders but access denied in any new folders k.king Linux - Networking 2 01-15-2006 07:14 AM
move files in tar.gz back to into original folders GUIPenguin Linux - General 1 05-09-2005 01:11 PM


All times are GMT -5. The time now is 01:24 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