Iterating OCI CLI list data in bash
For automating tasks with OCI, you have a few options: OCI CLI (bash) Python SDK Go SDK Java SDK REST API I'm a bash first kinda guy, so would usually opt for trying with the bash solution if the requirement is simple enough. Anything beyond, it's worth moving over to Python or GO. When you run a command, you will typically get a JSON payload. But I'm in bash, how to I interact with this data? That's where this nice tool jq comes in. An interface to JSON data, where you can pass in a json path to get the data you want. When you get started with this you will want to leverage the website jqplay.org . It provides a visual interface to the query paths you build, along with some common examples. So, now over to iterating the data structure. I'm going to take the compartment list as an example. When calling the command: oci iam compartment list, the data set in my tenancy looks like this: { "data": [ { "compartment-id":