Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract and delete all .gz in a directory- Linux

I have a directory. It has about 500K .gz files.

How can I extract all .gz in that directory and delete the .gz files?

like image 898
user2247643 Avatar asked Apr 16 '13 13:04

user2247643


People also ask

How unzip multiple gz file in Linux?

how can I extract multiple gzip files in directory and subdirectories? It will extract all files with their original names and store them in the current user home directory( /home/username ). gunzip *. gz // This command also will work.

How do you delete a .gz file?

To open (unzip) a . gz file, right-click on the file you want to decompress and select “Extract”. Windows users need to install additional software such as 7zip to open .


2 Answers

This should do it:

gunzip *.gz 
like image 181
Adrian Dunn Avatar answered Oct 18 '22 03:10

Adrian Dunn


@techedemic is correct but is missing '.' to mention the current directory, and this command go throught all subdirectories.

find . -name '*.gz' -exec gunzip '{}' \; 
like image 38
elhaj Avatar answered Oct 18 '22 01:10

elhaj