Question : Curl: how to get httpcode in Bash

Hi experts,

I know that I can use

curl -o $WEBSITEID "$URL"

to retrieve data from a url, however how to check if the retrieval is successful or not? In other words, how to get the response code (such as "200", or "404")?

Thanks for your replies.

Answer : Curl: how to get httpcode in Bash


1:
status=$(curl -s --head "$URL" | awk '/HTTP/ {print $2})
Open in New Window Select All
Random Solutions  
 
programming4us programming4us