Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
abc我有以下 yaml 文件,如果值中存在字符串,我正在尝试获取所有键值对 。
abc
a: abcsdf b: hyuabc c: iopabc d: mnhbvgc
预期输出:
a: abcsdf b: hyuabc c: iopabc
我的尝试:
yq eval '.[] | select(. == "*abc*") test.yaml
真的很奇怪,工作中的select和del功能完全不同。select 将过滤器的结果作为数组元素返回,而 delete 则返回地图
select
del
yq eval 'del( .[] | select( . != "*abc*" ) )' yaml