1

I uncompress file in the following way:

gunzip file.gz

But when I do it with pipe, it returns the error.

echo file.gz | gunzip
gzip: stdin: not in gzip format

What's the issue here? Thanks in advance.

1 Answer 1

1

The issue is that echo file.gz just echoes a string "file.gz". Basically the difference between the commands is:

What you want:

gunzip /path/to/directory/file.gz

What you're giving it with the echo:

gunzip "file.gz"

However, even this isn't entirely correct. The true difference is that instead of a reference to the file file.gz you're sending in only the string "file.gz"

I guess the real question here is why are you trying to pipe to gunzip instead of just using it as gunzip file.gz?

EDIT: It seems that doing echo file.gz | xargs gunzip does the trick, as well.

2
  • I see. I test with command "echo file.gz | xarg gunzip", it works! This is part of a shell script. The file name will be composed before this gunzip command. Dec 18, 2014 at 5:13
  • ok, cool. I hadn't thought to use xargs
    – Mitch
    Dec 18, 2014 at 5:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .