Search code examples
linuxarchivetar

How to untar all files from archive into one single folder, regardless from their folder nesting?


In one of my applications a user can upload images and archives (ZIP, RAR). When an archive is uploaded, it should be extracted. However, some users will upload archives that contain files in a variety of subfolders (within the archive)

What i am looking for is therefore a tar command that will extract ALL the files from within the archive into one single folder, no matter what the structure of the archive is.

Can this be done with a single command? And if yes, what would that command be?


Solution

  • Can this be done with a single command?

    No, tar does not support the -j flag like unzip does, or provide any alternative flag.

    Checkout the following alternatives:
    TAR – Extract discarding directory structure