How to remove an item of an array #1340
Answered
by
mikefarah
Evantage-WS
asked this question in
Q&A
-
|
Hi, Just (hopefully a simple) question: Is yq capable of removing the ".options.k3s.extraArgs" and then the - arg: with the value "-- flannel-backend=none' completely? Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
mikefarah
Sep 16, 2022
Replies: 2 comments 1 reply
-
|
Yep: yq 'del(.options.k3s.extraArgs[] | select(.arg == "--flannel-backend=none"))' file.yamlExplanation:
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Evantage-WS
-
|
This is working! Thanks! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yep:
yq 'del(.options.k3s.extraArgs[] | select(.arg == "--flannel-backend=none"))' file.yamlExplanation:
.options.k3s.extraArgs[]will match every item under extraArgsselect(.arg == "--flannel-backend=none")filters the items to only include the ones that have the matchingargvaluedelto delete those matching items