Question : Bash: curl and redirected url

Hi experts,

I know that
status=$(curl -s --head "$URL" | awk '/HTTP/ {print $2})
gives http code such as "200" or "404" Assume that the code is "310" ("moved permanently"), then how to use "curl" to retrieve the new url?

I googled but I got no answers.

Thanks for any replies.

Answer : Bash: curl and redirected url

NewURL=$(curl -s --head "$URL" | awk '/Location:/ {print $2}')
Random Solutions  
 
programming4us programming4us