Use curl -Is <url> to get the headers only in โsilentโ mode
Combine with grep -i <header> to match the desired header
Finally, use awk '{print $2}' to extract the second field, containing the value
curl -Is https://example.com | grep -i location | awk '{print $2}'