Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escaping colons in YAML

People also ask

How do you escape the special characters in YAML?

When double quotes, "...." , go around a scalar string you use backslash ( \ ) for escaping, and you have to escape at least the backslash and the double quotes. In addition you can escape other special characters like linefeed ( \n ) and escape an end-of-line by preceding it by a backslash.

How do I use a YAML file Colon?

A colon followed by a space (or newline) ": " is an indicator for a mapping. A space followed by the pound sign " #" starts a comment. …and then the colon will be preserved. The list of allowed escapes can be found in the YAML Specification under “Escape Sequences” (YAML 1.1) or “Escape Characters” (YAML 1.2).

How do I use special characters in YAML file?

Use quotes in YAML if your value includes special characters. For example, these special characters may require quotes: {, }, [, ], ,, &, :, *, #, ?, |. -, <. >, =, !, %, @, \. It is not necessary to use quotes when a single special character is surrounded by spaces, for example, * with spaces on both sides.


You'll need to put quotes around the key you're having trouble with. I.e.:

"8.11.32.120:8000": GoogleMapsKeyforThisDomain

To answer a comment another way for list items like:

- sed -i "s/driver: .*/driver: pdo_$DB/" etc/config.yaml

is to write them as:

- >-
  sed -i "s/driver: .*/driver: pdo_$DB/" etc/config.yaml

or as:

- 'sed -i "s/driver: .*/driver: pdo_$DB/" etc/config.yaml'