How to include an '&' character in a bash curl statement

Putting single quotes around the & symbol seems to work. That is, using a URL like http://www.example.com/page.asp?arg1=${i}'&'arg2=${j} with curl returns the requested webpage.


curl "http://www.example.com?m=method&args=1"

Are you using the & as a delimiter for a GET URL? Or is in a piece of data?

If it is in data you must encode it to an HTML character, if not, surround with quotes.

The encoding for & should become %26 in the URL.

curl "http://www.example.com?m=this%26that

Putting the entire URL inside double quotes should take care of your problem.

Tags:

Bash

Curl