Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 06-25-2009, 02:29 PM   #1
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?


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

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

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, 10:05 PM   #3
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, 01:47 PM   #4
LQ Newbie
Registered: Jun 2009
Posts: 2

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

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



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

All times are GMT -5. The time now is 08:18 AM.

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