I need help in finding "db-unique-name"
that has lifecycle-state": "AVAILABLE"
.
cat db_systems.txt
"db-unique-name": "p00z5bj_iad2bj",
"db-workload": "OLTP",
"defined-tags": {},
"freeform-tags": {},
"id": "dfadfasfsadfasdfasdf",
"lifecycle-details": null,
"lifecycle-state": "AVAILABLE",
--
"db-unique-name": "p00u5bh_iad2bj",
"db-workload": "OLTP",
"defined-tags": {},
"freeform-tags": {},
"id": "asdfsadfasdfasfd",
"lifecycle-details": "Resource was terminated at the backend.",
"lifecycle-state": "FAILED",
--
"db-unique-name": "p00u5bh_iad2bj",
"db-workload": "OLTP",
"defined-tags": {},
"freeform-tags": {},
"id": "asdfasdfasdf",
"lifecycle-details": "Resource was terminated at the backend.",
"lifecycle-state": "FAILED",
enter code here
Tried "db-unique-name"
value based on "lifecycle-state": "AVAILABLE"
. the following , but it gives wrong value
cat db_systems.txt | egrep -A -6 "lifecycle-state|AVAILABLE" | grep db-unique-name
"db-unique-name": "p00u5bh_iad2bj",
"db-unique-name": "p00u5bh_iad2bj",
I also tried this, but it is listing all of them
cat db_systems.txt | awk -F";" '{for(i=1;i<=NF;i++){if ($i ~ /AVAILABLE|db-unique-name/){print $1}}}' | grep db-unique-name
"db-unique-name": "p00z5bj_iad2bj",
"db-unique-name": "p00u5bh_iad2bj",
"db-unique-name": "p00u5bh_iad2bj",
oci network vcn list
or similar command would be), and the format looks as if it could have been JSON from the start.jq
generally rocks at parsing json from the command line.