Учитывая приведенный ниже JSON, я пытаюсь выбрать все элементы command
. Моя проблема в том, что строка "checkout"
испортила мой выбор всех "run"
диктов.
Я пытаюсь передать jq что-то вроде .[].run.command
, но постоянно получаю сообщение об ошибке jq: error (at <stdin>:33): Cannot index string with string "run"
Как исключить строку "checkout"
из выбранного?
[
"checkout",
{
"run": {
"command": "pip install cfn-lint pycodestyle pyflakes",
"name": "Install Dependencies"
}
},
{
"run": {
"command": "find stacks -type f -name \"*.yml\" -exec cfn-lint -i E3016 -i E3012 -i E1029 --template {} \\; | tee -a output.txt",
"name": "Run cfn-lint"
}
},
{
"run": {
"command": "find stacks -type f -name \"*.py\" -exec pyflakes {} \\; | tee -a output.txt",
"name": "Run pyflakes"
}
},
{
"run": {
"command": "pycodestyle --show-source --show-pep8 --ignore=E501,W605 stacks/src | tee -a output.txt",
"name": "Run pycodestyle"
}
},
{
"run": {
"command": "if [[ -s output.txt ]]; then cat output.txt; exit 1; fi",
"name": "Exit if there are validation warnings/errors"
}
}
]