Untar all archives in directory

I spotted someone today manually untaring about 45 archives in a single directory this morning and when I asked why they told me they didn’t know any better. So like I showed them, I am posting it here as well;

for a in `ls -1 *.tar.gz`; do tar -zxvf $a; done

This will list all files in the directory ending in tar.gz then run them through the tar utility to extract them, note this is for the bash shell.

Leave a Reply