I have a YAML that looks like
something:
- whatever:
- something
- toc: 4
- body: assets/footer.html
pkg:
- pkg_a_1:
- Shass
- AJh55
- ASH7
- pkg_b_1:
- Kjs6
- opsaa
other:
morestuff:
- whatever
I would like to pull out content under pkg and print them to a text file like this:
pkg_a_1 Shass
pkg_a_1 AJh55
pkg_a_1 ASH7
pkg_b_1 Kjs6
pkg_b_1 opsaa
I am trying to avoid using a full YAML parser as I only need this one section and nothing else from a large YAML file.
- The section label (pkg) is fixed, appears only once and does not change.
- The subsection label and the number of subsections (pkg_a_1, pkg_b_1) can change.
- The number of items and order of items under each subsection can change. Items can only contain
[A-Za-z0-9]+
. - Content before and after the pkg section can change. ie; the sections something: and other: may or may not be present.