0

I came across someone using the command zcat [filename].gz | less to open a file. What does | generally do when it's using in this manner? I've tried googling the question but haven't found the answer yet.

EDIT: actually the answer is here: What are the shell's control and redirection operators?

ghgh
  • 1

1 Answers1

2

| is called a pipe, its use is to direct the previous command's output to the second's input.
See here.
So in your example:

zcat [filename].gz | less

the outup of zcat is piped to less's input as if it were standard input. So your command is equivalent to:

less `zcat [filename.gz`

But be careful that the pipe only works between stdout and stdin, other file descriptors might give you weird results, or nothing at all.

joH1
  • 908