Dave L.
Dave L.

Reputation: 9801

Is it Possible to Output an Empty Value Using yq?

Using the yq tool, is there any way to make it assign/update a value to be empty (not empty string or null, just empty)?

For example, the current behavior is this:

yq eval --null-input '.a = "cat"'
a: cat

yq eval --null-input '.a = ""'      
a: ""

Whereas I want the output to be:

a: 

The reason is I want to maintain compatibility with the convention of a file I am working with.

Upvotes: 1

Views: 3326

Answers (1)

flyx
flyx

Reputation: 39768

If you set the tag to !!null, yq will output the scalar without quotes:

yq eval --null-input '.a="" | .a tag="!!null"'

Upvotes: 4

Related Questions