When you write a bash/zsh script relying on pipes normally you will not be able to pipe through text from the stderr output with a normal pipe.
curl -v prints some information about the request, including it’s headers and status into stderr.
If we simply try to pipe the output of
curl -v into
less we will not see the verbose header and request info:
curl -v https://hashrocket.com | less
Ruby on Rails, Elixir, React, mobile design and development | Hashrocket ...
But if we want the stderr output as well we can use the
curl -v https://hashrocket.com |& less
* Rebuilt URL to: https://hashrocket.com/ % Total % Received % Xferd Average Speed Time Time Time Current ... * Connected to hashrocket.com (184.108.40.206) port 443 (#0) ... ...
We can also pipe through ONLY the stderr:
curl -v https://hashrocket.com |1>& less
Output (will not contain the html response):
* Rebuilt URL to: https://hashrocket.com/ % Total % Received % Xferd Average Speed Time Time Time Current ...
h/t Thomas AllenTweet