Just in case it has already happened to you: For an unpacked TAR archive🗄️ no extra folder 📁 is created and the content is mixed with many other files in the same directory? How to clean up this mess⁉️
$ tar -tf Nice_Prog_RC1.tar.gz | xargs rm -r
With 'tar -tf' in only the content of the archive is displayed. This list of files is given to 'xargs', which passes it on to 'rm -r' for deletion. On the next try we better unpack the archive into an extra folder.👨💻
@datenteiler The famous extra-folder convention...
You never know if you have to cd into the final destination before extracting.
And that's the fastest way to clean up the mess if it occurs !
@datenteiler Nice - Thank you!
@datenteiler Nice solution, because I've done that exact thing on more than one occasion. I've usually done a second extract to a sub folder and then ran diffs against the files I didn't want to make sure I was getting what I wanted, but this solution is much more elegant.
@datenteiler Workaround for file names containing space or tab characters:
tar -tzf Nice_Prog_RC1.tar.gz | xargs -d '\n' -r rm -r
@datenteiler Very useful!!. Thanks for sharing.
@datenteiler i recommend the --one-top-level parameter for tar
@datenteiler you always have the "-C" option to put the contents in a separate folder. Really handy after an mkdir.
Fosstodon is an English speaking Mastodon instance that is open to anyone who is interested in technology; particularly free & open source software.