Cleaning up extracted package contents

I hate it when I download a source archive, uncompress it, and find that instead of creating a package directory, with the contents of the archive, the archive was created with a bunch of files at the root directory. Suppose I have a downloads directory with lots of archives. After I uncompress this new archive, I now have a bunch of archive files and a bunch of project specific files all in the same directory. Yuck.

 > cd downloads
 > tar -xzf latestdownload.tar.gz
 > # yuck, stupid package contents in my downloads directory.

Yeah, Yeah, I know I could have listed the package contents (tar -tzf ..) and found that I needed to create a directory first but I’m lazy. So the mess is there. Now to clean it up:

 > tar -tzf latestdownload.tar.gz | xargs rm -rf

There. Files gone. You can do the same thing with unzip -t for zip archives.

This entry was posted in System Administration and tagged , , . Bookmark the permalink.

One Response to Cleaning up extracted package contents

  1. Thank you! I often find myself in the same lazy situation as you described so this tip will be used many times.

Comments are closed.