In my shell script I am making an API call using cURL which is stored in variable named token_response, further I need to parse out value of key aws_access_key_id for which I am using sed as shown below. Wondering what's wrong with the pattern in sed which is not able to parse out desired key's value.
When trying to fetch using -
echo aws_access_key_id is:$(echo $token_response | sed -n 's/^.*"AccessKeyId":"\([^"]*\)",*$/\1/p')
JSON is stored in variable called - token_response
{
"Code":"Success",
"LastUpdated":"2018-12-27T07:16:31Z",
"Type":"fakedTypeValue",
"AccessKeyId":"fakedAccessKeyIdValue",
"Token":"fakedTokenValue"
}
Following is printed on console without the token value (Seems value for AccessKeyId is not parsed) -
aws_access_key_id is:
I expected following -
aws_access_key_id is:fakedAccessKeyIdValue