11

I want to unzip files which are in *.csv.gz format to .csv format.

When I tried with these commands $ gzip -d file.gz and $ gzip -f file.gz, it is showing like

gzip: IQ.gz: No such file or directory
gzip: Envoy.gz: No such file or directory
gzip: compressed data not read from a terminal. Use -f to force decompression.
For help, type: gzip -h

Please help me on this to how to unzip.

3
  • 1
    I'm not an expert in that field, but seeing your errors I would say there's no file names IQ.gz or envoy.gz where you run the command...
    – Laurent S.
    Jun 12, 2013 at 14:34
  • No, File is there. when i tried with -f option, it is not unzipping and taking too much time.
    – Dileep
    Jun 12, 2013 at 14:38
  • 3
    Is there a space in your filename (e.g. "IQ Envoy.gz")? If you try to gzip -d hello world.gz, gzip will search for the files "hello(.gz)" and "world.gz". Try gzip -d "hello world.gz" instead.
    – svk
    Jun 12, 2013 at 14:39

1 Answer 1

19
find . -name '*.csv.gz' -print0 | xargs -0 -n1 gzip -d

Should sort you, alternatively:

find . -name '*.csv.gz' -exec gzip -d {} \;

will also work. These are recursive so they will go into subdirs.

3
  • Hi, after using your command, my file name becomes 13232,1140,171540,1,"41401" and the content become empty. I am not sure why. Would you mind help or teach me how to undo the command? Thank you! Aug 12, 2021 at 22:48
  • Ask a separate question and link it here, with more detail and I'll be happy to take a look?
    – hd1
    Aug 12, 2021 at 23:05
  • unix.stackexchange.com/questions/664633/…. This is the updated link and thank you! Aug 14, 2021 at 5:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.