Skip to content

Replacing scalar from file #894

Answered by mikefarah
p3lim asked this question in Q&A
Jul 16, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Because you want to actually put the second file as string contents (rather than actual yaml) you will need to do something like this:

content=$(cat second.yaml) ./yq e  '.data.values = strenv(content)  | .data.values style= "literal"' first.yaml

Note that this will have |- and not | this means the trailing newline is _not_included :(

At the moment there is no way that I know of in the underlying go-yaml parser to get '|'

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mikefarah
Comment options

Answer selected by p3lim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants