skip to content
Alvin Lucillo

Interpret escape seq

/ 1 min read

💻 Tech

If you want echo to interpret escape sequences in the string when it’s written to a file, use -e argument like so: echo -e "var1=val1\nvar2=val2" > env1.env. With that argument, the .env file will have this content:

var1=val1
var2=val2

One example you might use this with is when creating a configmap out of an .env file:

echo -e "var1=val1\nvar2=val2" > env1.env
k create cm config1 --from-env-file=./env1.env

Without the argument, the .env file will just contain a one-line text.