How to grep curl -I header information

Posted by Mint on Stack Overflow See other posts from Stack Overflow or by Mint
Published on 2010-06-03T11:27:27Z Indexed on 2010/06/03 12:44 UTC
Read the original article Hit count: 160

Filed under:
|
|

Im trying to get the redirect link from a site by using curl -I then grep to "location" and then sed out the location text so that I am left with the URL.

But this doesn't work, it will outputs the URL to screen and doesn't put it

test=$(curl -I "http://www.redirectURL.com/" 2> /dev/null | grep "location" | sed -E 's/location:[ ]+//g')
echo "1..$test..2"

Which then outputs:

..2http://www.newURLfromRedirect.com/bla

Whats going on?

© Stack Overflow or respective owner

Related posts about linux

Related posts about redirect