Birchlabs Birchlabs - 1 year ago 98
Bash Question

Where did my backslashes go?

I have a JSON structure, escaped inside another JSON structure, escaped inside another JSON structure.

shows the file contents just fine:

Answer Source

The variable is being set to the correct value. You are either using dash, not bash, or your bash shell has the xpg_echo option set. The zsh built-in echo, though, behaves according to the POSIX specification, which replaces certain escaped characters. Try using printf instead:

$ printf '%s\n' "$X"
  "payload": "{\"data\":\"{\\\"nested\\\":1}\"}"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download