I’m trying to write a line in Bash that gets the Content-Type (without encoding) of a given URL. Thisi s what I have so far:
curl -Is http://www.google.com | sed -nr 's/^Content-Type: ([^;]*)/\1/Ip'
However, this is still printing text/html; charset=ISO-8859-1 and not just text/html. Shouldn’t ([^;]*) stop the match after the first semicolon?
What you want is:
Basically add a
.*after the matching group so that the part after text/html; will not be output.