Given a yaml file, I am looking for a yq command that will output a more "clean" list with only the relevant key "name" and its value.
for example, an output of the following yaml:
services:
- name: svc1
location: asia
timezone: india
- name: svc2
location: europe
timezone: uk
cities:
- london
- name: svc3
location: usa
timezone: east
cities:
- new-york
- brooklyn
Should be:
services:
- name: svc1
- name: svc2
- name: svc3
Which implementation of
yqare you using? In both, you can use thepickfunction to reduce an object to given keys, but their syntax is slightly different:Using mikefarah/yq (Tested with version 4.35.1):
Using kislyuk/yq (Tested with version 3.2.3):
Output: