I'd like to know what is the command to use to gunzip all files in a target directory recursively? I tried to use the unzip command but it didn't work.
I tried the command from Unzip all zip files in a target folder?
2 Answers
gunzip has -r option. From man gunzip :
-r --recursive Travel the directory structure recursively. If any of the
file names specified on the command line are directories, gzip
will descend into the directory and compress all the files it finds
there (or decompress them in the case of gunzip ).So, if you want to gunzip all compressed files (gunzip can currently decompress files created by gzip, zip, compress, compress -H or pack) inside the directory /foo/bar and all its subdirectories :
gunzip -r /foo/barThis will handle file names with spaces too.
0Using the commands below. Replace <path_of_your_zips> with the path to your ZIP files and <out> with your destination folder:
For GZ files
find <path_of_your_zips> -type f -name "*.gz" -exec tar xf {} -C <out> \;or
find <path_of_your_zips> -type f -name "*.gz" -print0 | xargs -0 -I{} tar xf {} -C <out>For ZIP files
find <path_of_your_zips> -type f -name "*.zip" -exec unzip {} -d <out> \;or
find <path_of_your_zips> -type f -name "*.zip" -print0 | xargs -0 -I{} unzip {} -d <out>