How do I unzip multiple files in a dir in Linux?

2 posts / 0 new
Last post
Anonymous
How do I unzip multiple files in a dir in Linux?

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.

guardianms
The following command can run

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