I want to merge two yaml files using yq in bash script.Selecting only specific keys values , removing duplicates and building a string.
file1.yaml
file2.yaml
FT1: false
FT2: false
FT3: false
FT4: false
Blah1: abc
Blah2: efg
Desired Output:
Trying to build a command like below.
- Filter any keys that starts with (FT*)
- join the key=values
- removing FT1, FT2 from file2.yaml
- And building a command for each key=value pair appending it with --from-literal=
--from-literal=FT1=true --from-literal=FT2=true --from-literal=FT3=false --from-literal=FT4=false
What I have tried so far:
yq eval '. | to_entries| .[] | select(.key == "FT*") | [.key, .value] | join("=") file1.yaml
The above command output is as below. Not sure how to merge them , remove duplicates from file2 and build the command.
file1.yaml
FT1=true FT2=true
I want to merge two yaml files using yq in bash script.Selecting only specific keys values , removing duplicates and building a string.
file1.yaml
file2.yaml
Desired Output:
Trying to build a command like below.
--from-literal=FT1=true --from-literal=FT2=true --from-literal=FT3=false --from-literal=FT4=falseWhat I have tried so far:
yq eval '. | to_entries| .[] | select(.key == "FT*") | [.key, .value] | join("=") file1.yamlThe above command output is as below. Not sure how to merge them , remove duplicates from file2 and build the command.
file1.yaml
FT1=true FT2=true