Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
tar – extract discarding directory structure

I have a tar file that include sub-directories each has several files. I need to extract all those files into one directory. Any help?

share|improve this question

marked as duplicate by Oliver Salzburg Aug 20 '12 at 13:09

This question was marked as an exact duplicate of an existing question.

Which operating system? Tag accordingly. – Daniel Andersson Aug 20 '12 at 7:24
@DanielAndersson I am using Ubuntu – Labibah Aug 21 '12 at 19:08
up vote 0 down vote accepted

Operating system not stated. Assuming some *nix-like variant.

Assuming TAR file tarfile.tar in the current directory:

mkdir temp dirwithfiles
tar xvf tarfile.tar -C temp
find temp -type f -exec mv -i {} dirwithfiles \;
rm -r temp

This will extract the full directory structure, then move all files within to the dirwithfiles directory.

Note mv -i since there might be several files with the same filename that need to be selected from.

share|improve this answer
It's almost uncanny how similar this is to the accepted answer in the question that was later linked as a duplicate. It's obvious enough to not qualify for a patent, though, so I think I'm in the clear. – Daniel Andersson Aug 22 '12 at 9:56

Not the answer you're looking for? Browse other questions tagged .