We’ll update a config file with sed

If we have a system variable

FILE_LOCATION="/home/tammo/file"

and a config file config.yaml

some-file: "FILE_LOCATION"

Then this command

sed -e "s|FILE_LOCATION|${FILE_LOCATION}|g;" config.yaml > output.yaml

will output this to output.yaml

some-file: "/home/tammo/file"

Note that it’s important here to use | as delimiter in the sed command, instead of /, because / is also used inside the replacement text.

Alternatively we could change config.yaml in place using -i

sed -i -e "s|FILE_LOCATION|${FILE_LOCATION}|g;" config.yaml
shadow-left