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
category:
- Uncategorized
tag: []
post_format: []
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
category:
- 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 |
+--------------+-----------------+-----------------+-----------------------------+
| 10.35.0.0/17 | My Primary VCN | AVAILABLE | myprimaryvcn.oraclevcn.com |
+--------------+-----------------+-----------------+-----------------------------+
</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'
"SILTFS_04.23.2019_19.21/CV_MAGNETIC/_DIRECTORY_HOLDER_",0
"SILTFS_04.23.2019_19.21/_DIRECTORY_HOLDER_",0