How to grep the output of cURL?
curl writes the output to stderr, so redirect that and also suppress the progress:
curl -v --silent https://google.com/ 2>&1 | grep expire
The reason why curl
writes the information to stderr is so you can do:
curl <url> | someprgram
without that information clobbering the input of someprogram
It is possible to use --stderr -
as parameter, to redirect the output from stderr (default) to stdout.
With this option you also should use --silent
to suppress the progress bar.
$ curl -v --silent https://google.com/ --stderr - | grep expire
* expire date: 2015-09-01 00:00:00 GMT