Unzip all gz files in all subdirectories of the terminal

Is there a way to unpack all the gz files into a folder containing the zip files. When zip files are in subdirectories. Request for

find -type f -name "*.gz"

      

Gives the following results:

./datasets/auto/auto.csv.gz
./datasets/prnn_synth/prnn_synth.csv.gz
./datasets/sleep/sleep.csv.gz
./datasets/mfeat-zernike/mfeat-zernike.csv.gz
./datasets/sonar/sonar.csv.gz
./datasets/wine-quality-white/wine-quality-white.csv.gz
./datasets/ring/ring.csv.gz
./datasets/diabetes/diabetes.csv.g

      

+3


source to share


2 answers


If you want, for each of them, run "gzip -d" on them:

gzip -d $(find ./ -type f -name '*.gz')

      



and then to gzip them back:

gzip $(find ./ -type f -name '*.csv')

      

+3


source


There is an option for recursion (-r).

gzip -dr ./datasets

      

The entire archive will be unpacked into its own directory.

Example: gzip -dr./a



a/b/c/test1.gz
a/b/d/test2.gz
a/e/test3.gz

      

After execution:

a/b/c/test1
a/b/d/test2
a/e/test3

      

+1


source







All Articles