0

I have a JSON file where items is an array and it has name three times in it.

How do I iterate the loop using shell script so that using a single script, it outputs the value of name for all the names in the array?

In my case, I should get the value of name three times.

Here is what I am doing right now:

curl ***** | jq '.items[0].name'
curl ***** | jq '.items[1].name'
curl ***** | jq '.items[2].name'

How can I create a script that automatically fetches however many times name appears in the items array and then prints them one by one? Is it possible using some for or while loop?

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
Ashley
  • 1,447
  • 3
  • 26
  • 52

0 Answers0