Home > database >  Terraform Setting a Bash Variable in local-exec How to Include a Line Break?
Terraform Setting a Bash Variable in local-exec How to Include a Line Break?

Time:09-24

In standard shell, you can include a line break as so:

  $a="line1\nline2"

But in this command:

resource "null_resource" "crypt_folio" {
    provisioner "local-exec" {
        command = "echo 'line1\nline2' > filo.txt"
    }
}  

It will fail.

How to properly escape a line break? I tried a second backslash, and this similarly failed.

CodePudding user response:

Putting the -e flag on may do the trick: echo -e 'line1\nline2' > filo.txt

  • Related