Replies: 1 comment
-
yq '
( select(.category == "sportscar" and (.title | contains(" Petrol"))) | .engine ) = "petrol" |
( select(.category == "sportscar" and (.title | contains(" Gasoline"))) | .engine ) = "petrol" |
( select(.engine == null) | .engine ) = "electric"
' file.yaml Note that you may be able to simplify your logic using RegEx: yq '
( select(.category == "sportscar" and (.title | test("(?i)\b(petrol|gasoline)\b"))) | .engine ) = "petrol" |
( select(.engine == null) | .engine ) = "electric"
' file.yaml This regex ignore case |
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
-
I have Front Matter files like this:
Using kislyuk's python-yq, I managed to accomplish my goal using following command:
THIS WORKS ONLY IF MD FILE HAVE NO CONTENT BELLOW ---
And I cant lose this content.
So I went to mikefarah's yq version. Because of that --front-matter=process option.
Actually this can process the md files, without mess with the content part
But this yq version dont work with If Elif Else approach.
So it throws me this error:
How can i make this conditional approach, without lose the content part of MD Files?
I have more than 2000 files to manage.... +80% has content bellow ---
Im working on MacOsx Terminal
I need this final scenario:
Beta Was this translation helpful? Give feedback.
All reactions