Unzip, untar, unpack all archives

Once I came to a point of having downloaded 20+ tar.gz files and facing a need of finding an efficient way to extract them. If you are having such a problem then this simple solution will help:

for F in `find ./ -type f -name '*tar.gz' -print`;
do tar xvzf $F;

What it does is for every file ending with “tar.gz” found in current folder “./” it executes a command “tar xvzf“, which unpacks the archive. Very simple but also VERY useful. Try with unzip and other commands.
Yes, you may delete files after unpacking by adding “rm $F;” after the tar statement.
However, it is always good to keep the original source!

This entry was posted in Linux. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *