How can I encode an url for wget?

3

I am looking for a way to convert a string to a clean url.

For example :

 wget http://myurl.com/toto/foo bar.jpg

This is going to download http://myurl.com/toto/foo and http://bar.jpg.

I want to download http://myurl.com/toto%20bar.jpg.

I tried some flag like --restrict-file-names=ascii but without success.

I do not want a way to encode not a kind of replace one-by-one.

Any idea ?

aloisdg moving to codidact.com

Posted 2014-03-12T17:46:22.517

Reputation: 277

You can try escaping the space by a backslash (\)... wget http://myurl.com/tot/foo%5C bar.jpg

– Ghassan – 2014-03-12T17:53:21.513

Answers

7

Contain the URL in quotes:

wget "http://myurl.com/toto/foo bar.jpg"

This is a general way of containing strings with spaces as a single argument.

Bendoh

Posted 2014-03-12T17:46:22.517

Reputation: 186

Damn ... I should think about this. Thank you. – aloisdg moving to codidact.com – 2014-03-12T18:11:19.487