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.
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.