This documentation is for Version 1 of the Amazon CLI only. For documentation related to Version 2 of the Amazon CLI, see the Version 2 User Guide.
Using quotation marks and literals with strings in the Amazon CLI
There are primarily two ways single and double quotes are used in the Amazon CLI.
Using quotation marks around strings that contain white spaces
Parameter names and their values are separated by spaces on the command line. If a string value contains an embedded space, then you must surround the entire string with quotation marks to prevent the Amazon CLI from misinterpreting the space as a divider between the value and the next parameter name. Which type of quotation mark you use depends on the operating system you are running the Amazon CLI on.
Optionally, you can separate the parameter name from the value with an equals sign
=
instead of a space. This is typically necessary only if the value of
the parameter starts with a hyphen.
$
aws ec2 delete-key-pair--key-name=-mykey
Using quotation marks inside strings
Strings might contain quotation marks, and your shell might require escaping quotations
for them to work properly. One of the common parameter value types is a JSON string.
This is complex since it includes spaces and double quotation marks " "
around each element name and value in the JSON structure. The way you enter
JSON-formatted parameters on the command line differs depending on your operating
system.
For more advanced JSON usage in the command line, consider using a command line JSON
processor, like jq
, to create JSON strings. For more information on
jq
, see the jq
repository