For Linux and macOS to interpret strings literally use single quotation marks ' '
to enclose the JSON data structure, as in the following example. You do not need to escape double quotation marks embedded in the JSON string, as they are being treated literally. Since the JSON is enclosed in single quotation marks, any single quotation marks in the string will need to be escaped, this is usually accomplished using a backslash before the single quote \'
.
$
aws ec2 run-instances \
--image-id ami-12345678 \
--block-device-mappings '
[{"DeviceName":"/dev/sdb","Ebs":{"VolumeSize":20,"DeleteOnTermination":false,"VolumeType":"standard"}}]'
For more information on using quotes, see the user documentation for your preferred shell.
Use single quotation marks ' '
or double quotation marks " "
.
Single quotations (recommended)
Single quotation marks ' '
are called verbatim
strings. The string is passed to the command exactly as you type it, which means PowerShell variables will not pass through.
Since JSON data structures include double quotes, we suggest single quotation marks ' '
to enclose it. If you use single quotation marks, you do not need to escape double quotation marks embedded in the JSON string. However, you need to escape each single quotation mark with a backtick `
within the JSON structure.
PS C:\>
aws ec2 run-instances `
--image-id ami-12345678 `
--block-device-mappings '
[{"DeviceName":"/dev/sdb","Ebs":{"VolumeSize":20,"DeleteOnTermination":false,"VolumeType":"standard"}}]'
Double quotations
Double quotation marks " "
are called expandable
strings. Variables can be passed in expandable strings.
If you use double quotation marks, you do not need to escape single quotation marks embedded in the JSON string. However, you need to escape each double quotation mark with a backtick `
within the JSON structure, as with the following example.
PS C:\>
aws ec2 run-instances `
--image-id ami-12345678 `
--block-device-mappings "
[{`"
DeviceName`"
:`"
/dev/sdb`"
,`"
Ebs`"
:{`"
VolumeSize`"
:20,`"
DeleteOnTermination`"
:false,`"
VolumeType`"
:`"
standard`"
}}]"
For more information on using quotes, see About Quoting Rules in the Microsoft PowerShell Docs.
WarningBefore PowerShell sends a command to the AWS CLI, it determines if your command is interpreted using typical PowerShell or CommandLineToArgvW
quoting rules. When PowerShell processes using CommandLineToArgvW
, you must escape characters with a backslash \
.
For more information on CommandLineToArgvW
in PowerShell, see What's up with the strange treatment of quotation marks and backslashes by CommandLineToArgvW in the Microsoft DevBlogs, Everyone quotes command line arguments the wrong way in the Microsoft Docs Blog, and CommandLineToArgvW function in the Microsoft Docs.
Single quotations
Single quotation marks ' '
are called verbatim
strings. The string is passed to the command exactly as you type it, which means PowerShell variables will not pass through. Escape characters with a backslash \
.
PS C:\>
aws ec2 run-instances `
--image-id ami-12345678 `
--block-device-mappings '
[{\"
DeviceName\"
:\"
/dev/sdb\"
,\"
Ebs\"
:{\"
VolumeSize\"
:20,\"
DeleteOnTermination\"
:false,\"
VolumeType\"
:\"
standard\"
}}]'
Double quotations
Double quotation marks " "
are called expandable
strings. Variables can be passed in expandable
strings. For double quoted strings you have to escape twice using `\
for each quote instead of only using a backtick. The backtick escapes the backslash, and then the backslash is used as an escape character for the CommandLineToArgvW
process.
PS C:\>
aws ec2 run-instances `
--image-id ami-12345678 `
--block-device-mappings "
[{`\"
DeviceName`\"
:`\"
/dev/sdb`\"
,`\"
Ebs`\"
:{`\"
VolumeSize`\"
:20,`\"
DeleteOnTermination`\"
:false,`\"
VolumeType`\"
:`\"
standard`\"
}}]"
Blobs (recommended)
To bypass PowerShell quoting rules for JSON data input, use Blobs to pass your JSON data directly to the AWS CLI. For more information on Blobs, see Blob.
The Windows command prompt requires double quotation marks " "
to enclose the JSON data structure. Also, to prevent the command processor from misinterpreting the double quotation marks embedded in the JSON, you must also escape (precede with a backslash \
character) each double quotation mark "
within the JSON data structure itself, as in the following example.
C:\>
aws ec2 run-instances ^
--image-id ami-12345678 ^
--block-device-mappings "
[{\"
DeviceName\"
:\"
/dev/sdb\"
,\"
Ebs\"
:{\"
VolumeSize\"
:20,\"
DeleteOnTermination\"
:false,\"
VolumeType\"
:\"
standard\"
}}]"
Only the outermost double quotation marks are not escaped.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4