I currently working on a script that updates a file. The file has several versions. The important ones have static links. These get redirected to the actual file which then gets downloaded using
wget. I have figured out that
wget has a flag whcih prints the headers recived. There is a list of Locations. The last location meantoned in the header is the actual URL. I need to get that!
My idea was to use
wget -S to get the header (I need another flag that prevents the file from downloading and creating). Then use a pipe to parse the lines and catch the last line containing
location. I guess this could be realized by using
grep -l -i "location:" | tail -l. Then I should be left with a single line that can be easily parsed.
So the command would look something like this:
# The -??? flag is the one that prevents the file from downloading. (I don't know it) Location=$(wget -S -??? $URL | grep -l -i "location:" | tail -l)
My question what flag do I have to use to not download the file with
wget or is there another way/command to accomplish this?