0

I have a JSON file (array) like this:

[
  {"name":"Joe","age":36},
  {"name":"John","age":14},
  {"name":"Linda","age":62}
]

And I want to parse it in shell, analyzing every item in the array, then to run a command for each item:

curl 'http://example.com/submit' -H --data 'name=[NAME]&age=[AGE]' 

Which is, in this case:

curl 'http://example.com/submit' -H --data 'name=Joe&age=36'
curl 'http://example.com/submit' -H --data 'name=John&age=14'
curl 'http://example.com/submit' -H --data 'name=Linda&age=62' 

I know how to do it with Node.jS but I really want to know how to achieve such operations in bash.

I am using zsh on ubuntu.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
AGamePlayer
  • 7,605

0 Answers0