delete entire document from multi-document file/input #2102
Answered
by
mikefarah
travisghansen
asked this question in
Q&A
-
I would like to remove an entire document (preferably by some selector, but by index would be crude enough) from the input.
I would like to remove any document for example which contains |
Beta Was this translation helpful? Give feedback.
Answered by
mikefarah
Jul 14, 2024
Replies: 2 comments 3 replies
-
I would use $ find -name "*.y*ml" -print0 | xargs -0 -r -- fgrep -L -v "kind: Namespace" You will get the list of files that do not contain "kind: Namespace" But it's possible someone could do it with yq |
Beta Was this translation helpful? Give feedback.
2 replies
-
Not currently on a machine with yq - but you should be able to do it like so
Explanation:
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
travisghansen
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not currently on a machine with yq - but you should be able to do it like so
Explanation:
select(.kind == "Namespace")
returns all the top level documents that matchdel( <exp>)
will delete those matchesdel(select(di == 0))
, see document index for more info :)