I have a directory full of tar.gz and zip files and I want to extract them in that directory with the least amount of effort.
Tue, 11/08/2011 - 09:00
#1
How do I unzip multiple files in a dir in Linux?
The following command can run from the shell or ssh to extract multiple files.
To unzip multiple zipped .zip, .gz, .tar.gz, bz2, or .tar.bz files:
$ for file in *.zip; do unzip "${file}"; done
To unzip multiple zipped .gz files:
$ gunzip *.gz
To unzip multiple zipped .bz2 files:
$ bunzip2 *.bz2
To extract multiple .tar.gz files:
$ for file in *.tar.gz; do tar -xzf "${file}"; done
To extract multiple .tar.bz2 files:
$ for file in *.tar.bz2; do tar -jxf "${file}"; done