Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 has been asked before and already has an answer. If those answers do not fully address your question, please ask a new 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

1 Answer 1

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 or ask your own question.