How to get response headers with cURL Command

How to get response headers with cURL Command

To see curl response headers, we need to use curl -I (Uppercase i) option.

curl -I example.com

To get curl response headers to a file, use the -D option or --dump-header option.

curl --dump-header headers.txt example.com

Or

curl -D headers.txt example.com

As per the above example, response headers will be saved to the 'headers.txt' file.