Wget recognizes part of my url as syntax error

I am brand new with wget and I did my research on google but couldn't find a hint.

I need to save one HTML file in a web page:

 wget yahoo.com -O test.html 

and it works, but when I try to be more specific:

 wget http://search.yahoo.com/404handler?src=search&p=food+delicious -O test.html 

a problem arises, wget recognizes &p=food+delicious as syntax, it says: 'p' is not recognized as an internal or external command

How can I solve this problem? I really appreciate your suggestions.

+4
source share
2 answers

& has special meaning in the shell. Select it with \ or put the URL in quotation marks to avoid this problem.

 wget http://search.yahoo.com/404handler?src=search\&p=food+delicious -O test.html 

or

 wget "http://search.yahoo.com/404handler?src=search&p=food+delicious" -O test.html 

In many Unix shells, after & after the command, it will be

+11
source

Wrap your URL in single quotes to avoid this problem.

i.e.

 wget 'http://search.yahoo.com/404handler?src=search&p=food+delicious' -O test.html 
+7
source

Source: https://habr.com/ru/post/1347596/


All Articles