Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6912143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:03:18+00:00 2026-05-27T09:03:18+00:00

Suppose I have a bash script that goes through a file that contains a

  • 0

Suppose I have a bash script that goes through a file that contains a list of old URLs that have all been redirected.

curl --location http://destination.com will process a page by following a redirect. However, I’m interested not in the content, but on where the redirect points so that I can update my records.

What is the command-line option for curl to output what that new location for the URL is?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:03:19+00:00Added an answer on May 27, 2026 at 9:03 am

    You wou want to leave out the --location/-L flag, and use -w, checking the redirect_url variable. curl -w "%{redirect_url}" http://someurl.com should do it.

    Used in a script:

    REDIRECT=`curl -w "%{redirect_url}" http://someurl.com`
    echo "http://someurl.com redirects to: ${REDIRECT}"
    

    From the curl man page:

    -w, --write-out <format>
    

    Make curl display information on stdout after a completed transfer. The
    format is a string that may contain plain text mixed with any number
    of variables. The format can be specified as a literal “string”, or
    you can have curl read the format from a file with “@filename” and to
    tell curl to read the format from stdin you write “@-“.

    The variables present in the output format will be substituted by the
    value or text that curl thinks fit, as described below. All variables
    are specified as %{variable_name} and to output a normal % you just
    write them as %%. You can output a newline by using \n, a carriage
    return with \r and a tab space with \t.

    NOTE: The %-symbol is a special symbol in the win32-environment, where
    all occurrences of % must be doubled when using this option.

    The variables available are:

    …
    redirect_url When an HTTP request was made without -L to follow
    redirects, this variable will show the actual URL a redirect would
    take you to. (Added in 7.18.2)
    …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's suppose I have a bash script ( foo.sh ) that in a very
Suppose you have a file that contains IP addresses, one address in each line:
Suppose we have a BASH script running some commands in the background. At some
For instance, I suppose I have a directory that contains the following folders foo_bar
I have a bash script that tries to call pgrep with arguments (Over simplified):
I have written (tried to) this small bash script for searching through a range
I'm using bash. Suppose I have a log file directory /var/myprogram/logs/ . Under this
Suppose I have a stringbuilder in C# that does this: StringBuilder sb = new
Suppose I have: Toby Tiny Tory Tily Is there an algorithm that can easily
Suppose I have a table called Companies that has a DepartmentID column. There's also

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.