I have tried both gzip and gunzip commands but I get either
gunzip *.gz
gzip: invalid option -- 'Y'
gunzip -S-1800-01-01-000000-g01.h5.gz
gzip: compressed data not read from a terminal. Use -f to force decompression. For help, type: gzip -hIf I try the -f option it takes a very long time to work on one single file and the command is not executed successfully. Am I missing something?
3 Answers
You can use below command.
Go to the directory where your .gz file is and run command:
for f in *.gz ; do gunzip -c "$f" > /home/$USER/"${f%.*}" ; doneIt will extract all file with original name and store it to current user home directory(/home/username). You can change it to somewhere else.
EDIT :
gunzip *.gzThis command also will work. But, by default, it replaces original file.
3Option # 1 : unzip multiple files using single quote (short version)
gunzip '*.gz'Note that *.gz word is put in between two single quote, so that shell will not recognize it as a wild card character.
Option # 2 : unzip multiple files using shell for loop (long version)
for g in *.gz; do gunzip $g; doneEDIT :
I have just tried :
gunzip -dk *.gzand it worked.
-d to decompress and k to keep original files.
Linux Users:
Use the following command for extracting minimum amount of .gz files in the current directory and its sub directories
gunzip *.gzUse the following command for extracting any number of .gz files in the current directory and its sub directories
sudo find . -name "*.gz" | xargs gunzip 1