I need to unzip all .gz files located in a directory. I don't want to save .gz file after unzipping.
I have tried below script:
#!/bin/bash
cd /data/path/ (move to desired directory)
for g in *.gz; do gunzip $g; done
But is seems that script ends up in loop and it never ends. Can you please help ?
CodePudding user response:
Try like this way, it won't keep .gz files after uncompress.
#!/bin/bash
cd /data/path ; gunzip *.gz
CodePudding user response:
You can execute the extract with one command:
gzip -d /data/path/*.gz
and gzip
will keep the uncompressed files in the same directory where are compressed.