This is an old revision of the document!
JQ stands for 'json query'
jq . # the dots means 'applies for all objects below'
aws ec2 describe-regions | jq -r "[[.Regions[].RegionName]]" aws ec2 describe-vpcs | jq -r "[[.Reservations[].Instances[].InstanceId]]" # extract all instances id (down 3 levels) aws ec2 describe-vpcs | jq -r '.Vpcs | length' # COUNT number of VPCs aws ec2 describe-vpcs --region eu-west-1 | jq -r '.Vpcs | length' # For a DIFFERENT Region
For containers/docker:
docker inspect --format '{{ json .State.Status }}' 47878c
docker inspect 47878c | jq .
oci compute instance list --compartment-id=$cb | jq -r '.data[]|select (."display-name"=="pepe37.lhr.oci.grapeshot.co.uk")'
oci compute instance list --compartment-id=$cb | jq -r '.data[]|select (."display-name" | contains("cc0"))' # like regex 'contains'
This filters with id but extracts the pair, not the key https://til.hashrocket.com/posts/uv0bjiokwk-use-jq-to-filter-objects-list-with-regex