Skip to content

Add option to convert keys to upper case #2505

@kknicker

Description

@kknicker

Add an option to convert keys to upper case, to be used with the "shell" output format. This is to produce output that conforms with the usual shell environment variable naming convention of upper case. And to make use of the environment variables in scripts more readable.

Based on a previous discussion Q&A about converting all keys to lower case case, the following appears to accomplish this. However, this is cumbersome for our use case of maintaining configuration files in YAML or JSON format and converting them at runtime for use in shell scripts.

yq '(.. | select(type == "!!map")) |= with_entries(.key |= upcase)' -o shell

We can of course wrap this in a shell function, so I won't be too disappointed if it isn't something that makes sense for yq to do natively.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions