0
votes

when I do wget as below, files are downloaded with filename as sample.txt?st=2017-07-19T06%3A00%3A00Z"

wget "https://sample.blob.core.windows.net/test/sample.txt?st=2017-07-19T06%3A00%3A00Z"

I don't want to use like below as It doesn't suits for my scenario.

wget -O $filename -q "https://sample.blob.core.windows.net/test/sample.txt?st=2017-07-19T06%3A00%3A00Z"

But I want to save filename as sample.txt when downloading using wget command. How to achieve this?

1
The stuff on the end of the file is called the query, and this answer on Superuser may be helpful.Daniel Lyons
@anubhava It doesn't suits me as I downloading more number of files. I don't want to provide every filename as static. Refer my question.Galet
You are any providing URL to be downloaded and filename can be derived from that URL easily.anubhava

1 Answers

3
votes

If my understanding is right, following script should work.

##set your blob url
url="https://sample.blob.core.windows.net/test/sample.txt?st=2017-07-19T06%3A00%3A00Z"
filename="${url%%[?]*}"; filename="${filename##*/}"

wget -O $filename -q $url

Note: If you use this script, your file name could not contain ?.