0

i try to put a bash script who'll get only the data value from the next request :

curl -H "X-Vault-Token: $VAULT_TOKEN" \
     -X GET http://127.0.0.1:8200/v1/secret/data/hello

but when i want to do | filter after :

curl -H "X-Vault-Token: $VAULT_TOKEN" \
     -X GET http://127.0.0.1:8200/v1/secret/data/hello | filter

It doesn't work.

I tried to switch to grep instead, but it didn't do what I expected.

I have the answer from my request :

{
  "request_id": "c1b3e19b-9f6b-a2af-1a1e-69b42bd9c81e",
  "lease_id": "",
  "renewable": false,
  "lease_duration": 0,
  "data": {
    "data": {
      "foo": "world"
    },
    "metadata": {
      "created_time": "2021-04-25T13:08:13.778097752Z",
      "deletion_time": "",
      "destroyed": false,
      "version": 1
    }
  },
  "wrap_info": null,
  "warnings": null,
  "auth": null
}

And i only want the field data, is anyone have encountered this ?

Léa Gris
  • 17,497
  • 4
  • 32
  • 41
The Nurse
  • 23
  • 2
  • 6
  • 1
    Does this answer your question? [Parsing JSON with Unix tools](https://stackoverflow.com/questions/1955505/parsing-json-with-unix-tools). Using`jq` to filter your JSON request answer, you would get the `data` member with: `curl -H "X-Vault-Token: $VAULT_TOKEN" -X GET http://127.0.0.1:8200/v1/secret/data/hello | jq -c '.data.data'` – Léa Gris Apr 25 '21 at 14:16
  • Yes ! thank you, it will help me – The Nurse Apr 25 '21 at 17:08

0 Answers0