Respectable projects release tar archives that contain a single directory, for instance zyrgus-3.18.tar.gz contains a zyrgus-3.18 folder which in turn contains src, build, dist, etc.But some punk projects put everything at the root :'-( This results in a total mess when unarchiving. Creating a folder manually every time is a pain, and unnecessary most of the time.Is there a super-fast way to tell whether a .tar or .tar.gz file contains more than a single directory at its root? Even for a big archive.Or even better, is there a tool that in such cases would create a directory (name of the archive without the extension) and put everything inside?
How to untar safely, without polluting the current directory in case of a tarbomb?
tar
patool handles different kinds of archives and creates a subdirectory in case the archive contains multiple files to prevent cluttering the working directory with the extracted files.Extract archivepatool extract archive.tarTo obtain a list of the supported formats, use patool formats.