Curl show Content-Type only
You can use the "-w" option too, with the "content-type" parameter:
curl -s -o /dev/null -w '%{content_type}' 'google.com'
Where:
-s: Silent mode, dont send any more to screen
-o: Output to file, and in this case, sends to /dev/null
-w: Where you show only with you want, in this case, content type
Reference: https://curl.haxx.se/docs/manpage.html
Option -F
is for forms. Instead you want to send a HEAD
request for retrieving only the response header without the response body by using option -I
.
To display an URL's content type:
curl -s -I www.google.nl | grep -i "^Content-Type:"
Here option -s
is added for silent mode for excluding the progress meter and error messages.
You can also specify the Accept
header in your HTTP request. This header is used to accept only specific content types:
curl -s -H "Accept: text/html" http://www.axmag.com/download/pdfurl-guide.pdf
But the disadvantage is that most webservers will serve you an error page which also has the content type text/html
. Hence you will still get a HTML file.