Using quotation marks with strings in IBM Cloud CLI
Depending on the operating system that you're running IBM Cloud® Command Line Interface on, you use either single or double quotation marks in the command. Linux™, macOS, the Windows™ command prompt (cmd.exe
), and Windows™ PowerShell
have different quotation-escaping requirements when you run commands. This difference impacts how you pass strings on the IBM Cloud® command line, including JSON content.
For Linux, macOS, or PowerShell, use single quotation marks ('). For the Windows command prompt, use double quotation marks ("). A JSON string requires double quotation marks around each name and value in the JSON structure. For more information, see the following examples.
Windows command prompt
For a Windows command prompt, use double quotation marks to surround the JSON data structure. Also, you must escape each double quotation mark that is inside the JSON structure by using a backslash before each double quotation mark.
ibmcloud resource service-instance-create my-service-instance db-service lite us-south -p "{\"units\":1}"
Linux or macOS
For Linux or macOS, use single quotation marks to surround the JSON data structure.
ibmcloud resource service-instance-create my-service-instance db-service lite us-south -p '{"units":1}'
Windows PowerShell
For PowerShell, use single quotation marks to surround the JSON data structure. Also, you must escape each double quotation mark that is inside the JSON structure by using a backslash before each double quotation mark.
ibmcloud resource service-instance-create my-service-instance db-service lite us-south -p '{\"units\":1}'