Can't use exclamation mark (!) in bash?
The exclamation mark is part of history expansion in bash. To use it you need it enclosed in single quotes (eg: 'http://example.org/!132'
) or to directly escape it with a backslash (\
) before the character (eg: "http://example.org/\!132"
).
Note that in double quotes, a backslash before the exclam prevents history expansion, BUT the backslash is not removed in such a case. So it's better to use single quotes, so you're not passing a literal backslash to curl
as part of the URL.
As well as the answer given by Daniel, you can also simply turn off history expansion altogether if you don't use it with set +H
.
I would personally do single quotes, but for completeness, I will also note since it is a URL, you can encode the !
as %21
, e.g. curl -v http://example.org/%21132
.