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
-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to cURL,
- Hide cURL Outputs and Errors on Terminal
- cURL DELETE Request with Examples
- Downloading Google Chrome using cURL Command
- List of 28 Protocols supported by cURL with Examples
- Get the Size of HTTP Response using cURL Command (Content Length)
- How to convert a Postman request to cURL Command
- How to URL Encode Data for a cURL Request Parameters
- Get cURL command from Chrome Inspect Network HTTP URL
- Fetch only content-type using cURL Command
- cURL -d Option with Examples
- cURL Option to show HTTP Response Status Code
- URL Encode cURL HTTP GET\POST Data with Examples
- How to get cURL Command to run in verbose mode?
- trurl: A new command-line tool for URL parsing and manipulation by cURL Developer
- [fix] command not found curl
- How to Pretty Print cURL JSON Output in Terminal
- Capture cURL Request Output to a File
- List of common cURL Error Codes
- How to pass authorization header using cURL
- Perform Basic Authentication using cURL with Examples
- Trace using cURL Command Example
- Efficient way to perform HTTP cURL GET/POST Requests with Payload
- Save cURL Command Output to a external file
- cURL Example using IP (IPv4 and IPv6) address and Port
- How to follow redirects in cURL Command Request
More Posts:
- jQuery: Check if an element exists or not - jQuery
- [Solution] Spring Tool Suite (STS) support for JSP (JAVA EE) - Eclipse
- Install Python on Alpine Linux - Docker - Docker
- YAML Parser using Java Jackson Library Example - Java
- How to Configure GitHub with Eclipse IDE in 2023 - Eclipse
- Java 8: Steam map with Code Examples - Java
- How to pretty print HTML using Java Code - Html
- [Fix] Microsoft Windows OneDrive 0x8007018b Error Code - Windows