Find the answer to your Linux question:
Results 1 to 4 of 4
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, ...
  1. #1
    Just Joined!
    Join Date
    Jun 2009
    Posts
    2

    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
    Last edited by canadatom; 06-26-2009 at 06:24 PM. Reason: problem solved

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,970
    I don't know of a way to do that with 'tar'. I just read thru the manpage and could not find anything there either. What I would do is to extract the tarball and then use the 'find' command to move all the files to the current directory. Ie,
    Code:
    tar -xzvf tarball
    find . -type -exec mv -f {} . \;
    You might see some warnings from 'mv' about files being the same, and if there are duplicate file names in the archive, then what you get in your local directory will be the last one found. If you leave off the -f argument from mv, then you will be asked if you want to overwrite duplicate-named files. Finally, remove the directories created by extracting the archive.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Jun 2009
    Posts
    2
    this is really helpful, I think shell script method works.

    I also tried using 7-zip to unzip the tar.gz file by typing:
    Code:
    7z e filename.tar.gz
    it will automatically extract all the files into current directory.

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,970
    Quote Originally Posted by canadatom View Post
    this is really helpful, I think shell script method works.

    I also tried using 7-zip to unzip the tar.gz file by typing:
    Code:
    7z e filename.tar.gz
    it will automatically extract all the files into current directory.
    Well, that's certainly easier. Haven't used 7zip much, so that's good to know. TAL for the info.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...