Skip to content

Oci cli query

wordpress meta

title: 'OCI Cli Query'
date: '2019-04-24T15:49:06-05:00'
status: publish
permalink: /oci-cli-query
author: admin
excerpt: ''
type: post
id: 1351
    - Uncategorized
tag: []
post_format: []

If you want to manipulate the output of Oracle Cloud Infrastructure CLI commands you can pipe output through jq. I have examples of jq elsewhere. You can also use the query option like follow.

``` $ oci network vcn list --compartment-id <> --config-file <> --profile <> --cli-rc-file <> --output table --query 'data [*].{"display-name":"display-name", "vcn-domain-name":"vcn-domain-name" "cidr-block":"cidr-block", "lifecycle-state":"lifecycle-state"}' +--------------+-----------------+-----------------+-----------------------------+ | cidr-block | display-name | lifecycle-state | vcn-domain-name | +--------------+-----------------+-----------------+-----------------------------+ | | My Primary VCN | AVAILABLE | | +--------------+-----------------+-----------------+-----------------------------+
</div>And for good measure also a jq example. Plus csv filter.

<div class="wp-block-syntaxhighlighter-code ">```

$ oci os object list --config-file /root/.oci/config --profile oci-backup --bucket-name "commvault-backup" | jq -r '.data[] | [.name,.size] | @csv'