• Try my compact version ;)

    #!/usr/bin/env bash
    
    yq -oj | jq -e --arg KEY ${1:-item} '. as $input
    | [path(..) | select(last == $KEY)]
    | [foreach .[] as $item (null; $input | getpath($item))]
    | unique | {$KEY: .}'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment