Retrieve the final URL after redirect

curl $URL -s -L -o /dev/null -w '%{url_effective}'
Sometimes it could be very useful to obtain the final URL you'll use after several redirects. (I use this command line for my automated tests to check if every redirections are ok)
Sample Output
$ curl http://google.com -s -L -o /dev/null -w '%{url_effective}'
http://www.google.fr/

0
By: labynocle
2012-01-25 16:11:24

These Might Interest You

  • change the nfl in the url to mlb or nba to get those score/times as well Show Sample Output


    2
    w3m -no-cookie http://m.espn.go.com/nfl/scoreboard?|sed 's/ Final/ : Final/g'|sed 's/ F\// : F\//g'|sed 's/, / : /g'|grep -i ':'
    SQUIIDUX · 2010-11-15 01:18:19 3
  • w3m is a commanline web browser, full of options, I used -dump_head for less unnecessary page download. With awk, I can retrieve dynamic changes in webpages in this very econnomical fashion Show Sample Output


    -1
    w3m -dump_head www.fiat.com | awk '/Date+/{print $6, $7}'
    m33600 · 2009-06-08 00:06:01 0
  • Tres lineas en un shell script para copiar la base de datos diaramente


    -2
    FECHA=$(date +"%F") FINAL="$FECHA.sql.gz" mysqldump -h localhost -u user --password="pass" --opt jdiaz61_lupajuridica | gzip > /home/jdiaz61/www/backup/$FINAL
    juancabo · 2009-08-09 14:51:46 2
  • If you have tried to change your prompt and made a mistake, use this command to retrieve a standard prompt. If you used the export command when you changed your prompt, also use it there: export PS1='$PWD$ '


    -2
    PS1='$PWD$ '
    Aldiansblog · 2009-02-13 22:00:57 0

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: