According to man gzip:
"If no files are specified, or if a file name is "-", the standard input is compressed to the standard output."
In all your cases you piping source stream to gzip's STDIN without specifying content to compress as a source file. In these cases gzip sends compressed stream to STDOUT by default that makes -c option useless/redundant.
The -c option is useful when you calling gzip as gzip -c sourceFile so in this case instead of
compressing sourceFIle+adding extension GZ+deleting sourceFile
it will send compressed stream to STDOUT and won't delete sourceFile.
For example:
gzip -c sourceFile | anotherProgram
gzipdecides the output mode based on>redirect, but rather if the input files are a) specified as CLI parameters or b) piped in using|. So the-cwould be mandatory in this casegzip -c file1 file2 > foo.gz, but not for thiscat file1 file2 | gzip > foo.gz. – Vlastimil Ovčáčík Aug 21 '18 at 15:10>redirect", but I used phrase that ended with: "in your use case".-cisn't mandatory if one want to compress file1 and file2 (gzip file1 file2) separately even it's CLI. According toman gzipall-cis doing is: "Write output on standard output; keep original files* unchanged."* – Alex Aug 21 '18 at 15:49-chas no effect since he is using stdout redirect. You are right about that gzip defaults to stdout in his use case, but not for the reason you wrote. – Vlastimil Ovčáčík Aug 21 '18 at 16:59man gzipto clarify the reason whygzipignores-coption in cases like redirect/pipe where no source file(s) are specified. I hope that's what you mention. – Alex Aug 21 '18 at 17:28gzipcommand. What matters is that there is pipe before it. I was not talking about the trailing|but about the leading one. I probably didn't make this clear, but if you reread my comments with this in mind it should make sense. Otherwise I am sorry for bothering you. – Vlastimil Ovčáčík Aug 21 '18 at 17:59