0

How can I extract the base64 value shown below? I was trying to use something like awk {'print $14'}, but this doesn't work because the entire output is first item. If I decode the base64 value first, then I'm able to use awk {'print $14'} to eventually obtain the value that I need.

$ curl -s --request GET http://10.0.10.10:8500/v1/kv/w-key-value

[{"LockIndex":0,"Key":"w-key-value","Flags":0,"Value":"WyAgeyAgICBDcmVhdGVJbmRleDogMTAwLCAgICBNb2RpZnlJbmRleDogMjAwLCAgICBMb2NrSW5kZXg6IDIwMCwgICAgS2V5OiB6aXAsICAgIEZsYWdzOiAwLCAgICBWYWx1ZTogMSAgICBTZXNzaW9uOiBhZGY0MjM4YS04ODJiLTlkZGMtNGE5ZC01YjY3NThlNDE1OWUgIH1d","CreateIndex":4080,"ModifyIndex":4080}]
2
  • With GNU grep: grep -Po '"Value":"\K[^"]*' file or with GNU sed: sed 's/,/\n/g' file | sed -nE 's/^"Value":"(.*)"/\1/p' Commented May 14, 2018 at 1:55
  • Great! that works. thanks. Commented May 14, 2018 at 4:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.