If you only want to fetch the content-type for a response, make use of the --write-out option and the variable content_type
Example:% curl -s -o /dev/null -w "%{content_type}\n" http://example.org
Output:
text/html; charset=UTF-8

You may also make use of the -I option along with grep,
% curl -I http://example.org
HTTP/1.1 200 OK
Content-Encoding: gzip
Accept-Ranges: bytes
Age: 584814
Cache-Control: max-age=604800
Content-Type: text/html; charset=UTF-8
Date: Mon, 12 Dec 2022 11:33:10 GMT
Etag: "3147526947"
Expires: Mon, 19 Dec 2022 11:33:10 GMT
Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
Server: ECS (dcb/7F60)
X-Cache: HIT
Content-Length: 648
Example:
% curl -Is http://example.org | grep -iF 'Content-Type'
Output:
Content-Type: text/html; charset=UTF-8
-
Have Questions? Post them here!
More Posts related to cURL,
- cURL Example using IP (IPv4 and IPv6) address and Port
- Efficient way to perform HTTP cURL GET/POST Requests with Payload
- Save cURL Command Output to a external file
- How to set Connection and Max Timeout for cURL Request with Examples
- [fix] command not found curl
- Fetch only content-type using cURL Command
- Trace using cURL Command Example
- Hide cURL Outputs and Errors on Terminal
- cURL Option to show HTTP Response Status Code
- Downloading Google Chrome using cURL Command
- Perform Basic Authentication using cURL with Examples
- List of 28 Protocols supported by cURL with Examples
- URL Encode cURL HTTP GET\POST Data with Examples
- Get the Size of HTTP Response using cURL Command (Content Length)
- How to get cURL Command to run in verbose mode?
- Get cURL command from Chrome Inspect Network HTTP URL
More Posts:
- What is Microsoft 365 Message You are using more licenses on your trial than what you will purchase once the free trial ends. - Microsoft
- How to get cURL Command to run in verbose mode? - cURL
- How to Clone Bitbucket repository to Local Computer - Git
- zsh: exec format error eclipse M1 Mac - zsh
- [fix] zsh: command not found: git - Git
- 300+ Eclipse IDE Keyboard Shortcuts for Mac - Eclipse
- How to install Zsh shell - HowTos
- Setting up Zsh Syntax Highlighting - zsh