title: Get all nested urls based on nested tag in JSON
body: <p>I have a following Json input in a text file <code>json.txt</code>:</p>
  <pre><code>{
     &quot;files&quot;:[
        {
           &quot;id&quot;:49894894,
           &quot;list&quot;:[
              {
                 &quot;name&quot;:&quot;one&quot;,
                 &quot;animal_potato_carrot&quot;:{
                    &quot;options&quot;:[
                       {
                          &quot;id&quot;:4989,
                          &quot;url&quot;:&quot;https://example.com/text.txt&quot;
                       },
                       {
                          &quot;id&quot;:3994,
                          &quot;url&quot;:&quot;https://example.com/randomfile.json&quot;
                       }
                    ]
                 }
              },
              {
                 &quot;name&quot;:&quot;two&quot;,
                 &quot;cat_dog_rabbit&quot;:[
                    {
                       &quot;id&quot;:4989,
                       &quot;url&quot;:&quot;https://example.com/text2.txt&quot;
                    },
                    {
                       &quot;id&quot;:3994,
                       &quot;url&quot;:&quot;https://example.com/randomfile.json&quot;
                    }
                 ]
              },
              {
                 &quot;name&quot;:&quot;three&quot;,
                 &quot;animal_potato_carrot&quot;:{
                    &quot;options&quot;:[
                       {
                          &quot;id&quot;:4989,
                          &quot;url&quot;:&quot;https://example.com/text3.txt&quot;
                       },
                       {
                          &quot;id&quot;:3994,
                          &quot;url&quot;:&quot;https://example.com/randomfile.json&quot;
                       }
                    ]
                 }
              }
           ]
        }
     ]
  }
  </code></pre>
  <p>I want to get only the first url in the list of <code>options</code> for each <code>animal_potato_carrot</code> or <code>cat_dog_rabbit</code> nested tag only (note they have different structures)</p>
  <p>So my output will be first three urls in those blocks:</p>
  <pre><code>[&quot;https://example.com/text.txt&quot;, &quot;https://example.com/text2.txt, &quot;https://example.com/text3.txt&quot;]
  </code></pre>
  <p>I tried <code>jq json.txt -c '.. |.&quot;animal_potato_carrot&quot;? | select(. != null)'</code> but that returns all the things inside the body, not just the FIRST url.</p>
  <p>Edit:</p>
  <p>these two commands return the urls for <code>animal_potato_carrot</code> and <code>cat_dog_rabbit</code> separately but is there a way to combine these commands?</p>
  <pre><code>jq -c '[..|.animal_potato_carrot?|select(. != null)|.options[0].url]' json.txt
  </code></pre>
  <pre><code>jq -c '[..|.cat_dog_rabbit?|select(. != null)|.[0].url]' json.txt
  </code></pre>