Read a YAML file to a string #1336
-
Can we use e.g. test:
a: b and what I want is |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Not entirely sure what you want here - as the file is already a string. I think you probably need to use the encoder operator detailed here: https://mikefarah.gitbook.io/yq/operators/encode-decode |
Beta Was this translation helpful? Give feedback.
-
Since yq's output is already a string, you can do any kind of conversion you want on that output. Would this work for you? yq '.' file.yaml | awk '{printf "%s\\n", $0}' |
Beta Was this translation helpful? Give feedback.
-
Oh I see, you can get the same result using the 'sub' command to replace newlines with \n, no need for awk.
…________________________________
From: Julian Barg ***@***.***>
Sent: Friday, September 23, 2022 7:38:56 AM
To: mikefarah/yq ***@***.***>
Cc: Mike Farah ***@***.***>; Comment ***@***.***>
Subject: Re: [mikefarah/yq] Read a YAML file to a string (Discussion #1336)
Since yq's output is already a string, you can do any kind of conversion you want on that output. Would this work for you?
yq '.' file.yaml | awk '{printf "%s\\n", $0}'
—
Reply to this email directly, view it on GitHub<#1336 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAIZHNIDEMTCYZWD3RYES73V7TUZBANCNFSM6AAAAAAQMTTTTM>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Since yq's output is already a string, you can do any kind of conversion you want on that output. Would this work for you?